Get vector of variable values

get_var_values(x, data)

Arguments

x

Either a name (string) or a positive integer which indicates position of variable in data or a vector.

data

A data frame (or sililar structure).

Value

  • If x is a vector of at least 2 elements, this vector is returned.

  • If x is a string or a number (length 1), then data[[x]] is returned.

  • If x is NULL, NULL is returned.

Examples

library(manyROC) dataset <- head(PlantGrowth) get_var_values(x = "group", data = dataset)
#> [1] ctrl ctrl ctrl ctrl ctrl ctrl #> Levels: ctrl trt1 trt2
get_var_values(x = c("group", "group"), data = dataset)
#> [1] "group" "group"
get_var_values(x = NULL, data = dataset)
#> NULL