scb_search: Search for directory or table in database cache

Description Usage Arguments Details Examples

Description

Uses data.frame subsetting along with grepl to return all rows in scb_cache that matches the provided arguments. Arguments that are skipped are ignored. The function uses data/scb_cache.rda by default, but this can be overriden via the cached_database argument.

Usage

1
2
3
scb_search(search_id = NULL, search_type = NULL, search_name = NULL,
  search_var_desc = NULL, search_val_desc = NULL, search_year = NULL,
  cached_database = NULL, ignore_case = FALSE)

Arguments

search_id

Directory or table ID path

search_type

"l" for directory, "t" for table

search_name

Regex for directory or table name

search_var_desc

Rexeg for variable descriptions: table only

search_val_desc

Regex for value descriptions: table only

search_year

Year for which there is data: table only

cached_database

See scb_cache

ignore_case

Is regex case sensitive - passed to grepl

Details

The subsetting starts with the type argument, to quickly separate databases and tables; this is done as a simple data.frame subsetting operation, matching either "l" or "t". The function then goes through the rest of the arguments, and uses grepl to match the string or regex provided in the relevant column.

If type is not specified but any search term other than ID is, the function will default to table search as the other search variables are only present in tables. In this case, a warning is provided.

This function is subject to change as the caching function is improved.

Examples

1
2
3
4
5
6
## Not run: 
scb_search(search_id = "AM/AM0101")
scb_search(search_type = "t", search_name = "LFS", ignore_case = TRUE)
scb_search(search_type = "t", search_var_desc = "overtime")

## End(Not run)

olhmr/rscb documentation built on May 15, 2019, 10:40 p.m.