The look_for()
function is designed to emulate the functionality of the Stata lookfor
command in R. It provides a powerful tool for searching through large datasets, specifically targeting variable names, variable label descriptions, factor levels, and value labels. This function is handy for users working with extensive and complex datasets, enabling them to quickly and efficiently locate the variables of interest.
look_for(
data,
...,
labels = TRUE,
values = TRUE,
ignore.case = TRUE,
details = c("basic", "none", "full")
)
A tibble data frame featuring the variable position, name and description (if it exists) in the original data frame.
a data frame or a survey object
optional list of keywords, a character string (or several
character strings), which can be formatted as a regular expression suitable
for a base::grep()
pattern, or a vector of keywords;
displays all variables if not specified
whether or not to search variable labels (descriptions);
TRUE
by default
whether or not to search within values (factor levels or value
labels); TRUE
by default
whether or not to make the keywords case sensitive;
TRUE
by default (case is ignored during matching)
add details about each variable (full details could be time
consuming for big data frames, FALSE
is equivalent to "none"
and TRUE
to "full"
)
look_for(iris)
# Look for a single keyword.
look_for(iris, "petal")
look_for(iris, "s")
Run the code above in your browser using DataLab