data_seek | R Documentation |
This functions seeks variables in a data frame, based on patterns
that either match the variable name (column name), variable labels, value labels
or factor levels. Matching variable and value labels only works for "labelled"
data, i.e. when the variables either have a label
attribute or labels
attribute.
data_seek()
is particular useful for larger data frames with labelled
data - finding the correct variable name can be a challenge. This function
helps to find the required variables, when only certain patterns of variable
names or labels are known.
data_seek(data, pattern, seek = c("names", "labels"), fuzzy = FALSE)
data |
A data frame. |
pattern |
Character string (regular expression) to be matched in |
seek |
Character vector, indicating where
|
fuzzy |
Logical. If |
A data frame with three columns: the column index, the column name
and - if available - the variable label of all matched variables in data
.
# seek variables with "Length" in variable name or labels
data_seek(iris, "Length")
# seek variables with "dependency" in names or labels
# column "e42dep" has a label-attribute "elder's dependency"
data(efc)
data_seek(efc, "dependency")
# "female" only appears as value label attribute - default search is in
# variable names and labels only, so no match
data_seek(efc, "female")
# when we seek in all sources, we find the variable "e16sex"
data_seek(efc, "female", seek = "all")
# typo, no match
data_seek(iris, "Lenght")
# typo, fuzzy match
data_seek(iris, "Lenght", fuzzy = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.