The apropos()
function in R is used to return a character vector with the names of objects matching or containing the input character partially.
The find()
function, on the other hand, is used to return a location where the objects of a given name can be found.
apropos(what, where = FALSE, ignore.case = TRUE, mode = "any")
find(what, mode = "any", numeric = FALSE, simple.words = TRUE)
The apropos()
and the find()
functions take a common mandatory parameter value, what
, which represents the string character to match object names against.
where
, numeric
: This takes a logical value indicating whether positions in the search list should also be determined.ignore.case
: Takes a logical value indicating if the search should be case-sensitive or not. It has its default value as TRUE
.mode
: Represents the character. if not "any"
, only the objects whose mode
equals mode
are searched for.simple.words
: Takes a logical value. If TRUE
, the what
parameter is only searched as a whole word.The apropos()
function returns a character vector which is sorted by name.
The find()
function returns the character vector of environment names or numerical vectors of positions with names of the corresponding environments.
In the code below, we’ll identify all the R objects with names containing "var"
using the apropos()
function. And pick one of the output results to determine the environment where the object can be found.
# checking for R objects which contains "var" as its name or partiallyapropos("var")
We use the apropos()
function to obtain the objects in R matching the name character "var"
.
From the output of the code:
[1] ".expand_R_libs_env_var" "all.vars" "estVar"
[4] "get_all_vars" "globalVariables" "var"
[7] "var.test" "variable.names" "varimax"
We have a list of R objects matching the name character var
as seen in the code above.
From the output of the code, we use the find()
function to determine the location of the object "all.vars"
as seen in the output of the previous code.
# using the find() function to return the location of the object "all.vars"find("all.vars")
We use the find()
function to determine the location of the R object, "all.vars"
. From the code’s output, the object can be located in the environment named "package:base"
.