This function searches for specified keywords across columns in a data frame and returns only the rows where at least one keyword appears in any of the specified columns. It supports nested columns (lists within columns) and provides the option to limit the search to specific columns.
Arguments
- data
A data frame to search. It can include nested columns (lists within columns).
- keywords
A character vector of keywords to search for within the specified columns. The search is case-insensitive.
- columns
Optional. A character vector of column names to limit the search to specific columns. If
NULL
, all columns indata
will be searched.
Value
A data frame containing only the rows where at least one keyword is
found in the specified columns. The returned data frame has the same
structure as data
.
Examples
if (FALSE) { # \dontrun{
# Download indicators
indicators <- wdi_get_indicators()
# Search for keywords "inequality" or "gender" across all columns
wdi_search(
indicators,
keywords = c("inequality", "gender")
)
# Search for keywords only within the "indicator_name" column
wdi_search(
indicators,
keywords = c("inequality", "gender"),
columns = c("indicator_name")
)
} # }