R: Find variables by name

findvar {rccmisc} | R Documentation

## Find variables by name

### Description

Function to seacrh for a variable by its name. See the "Value" section for more details on the different functions.

### Usage

    findvar_fun(df, ...)

    findvar_in_df(pattern, df, ...)

    findvar_anywhere(pattern, envir = .GlobalEnv, ...)

### Arguments

`df` | A data.frame from where the column names should be identified when returned function applied
`...` | Arguments passed to `grep`
`pattern` | A character string with name (or part of name) of the variables to find.
`envir` | environment holding data.frames where to search for the variables (the Global environment as default).

### Value

- `findvar_fun`: A function with argument `param` to search for `param` in `df`. See example!

- `findvar_in_df`: A vector with variable names from df matching the pattern.

- `findvar_anywhere`: Does not return anything but prints a message where variables matching the pattern can be found.

### Examples

    find_cars <- findvar_fun(cars)
    find_cars("sp")

    findvar_in_df("sp", cars)

    cars <- cars; iris <- iris
    findvar_anywhere("petal")

[Package rccmisc version 0.3.7 Index]