data_dict_filter | R Documentation |
Subsets either or both the 'Variables' and 'Categories' elements of a data
dictionary. Rows are conserved if their values satisfy the condition.
This is a wrapper function analogous to dplyr::filter()
.
data_dict_filter(
data_dict,
filter_var = NULL,
filter_cat = NULL,
filter_all = NULL
)
data_dict |
A list of data frame(s) representing metadata to be filtered. |
filter_var |
Expressions that are defined in the element 'Variables' in the data dictionary. |
filter_cat |
Expressions that are defined in the element 'Categories' in the data dictionary. |
filter_all |
Expressions that are defined both in the 'Categories' and 'Variables' in the data dictionary. |
A data dictionary contains the list of variables in a dataset and metadata
about the variables and can be associated with a dataset. A data dictionary
object is a list of data frame(s) named 'Variables' (required) and
'Categories' (if any). To be usable in any function, the data frame
'Variables' must contain at least the name
column, with all unique and
non-missing entries, and the data frame 'Categories' must contain at least
the variable
and name
columns, with unique combination of
variable
and name
.
A list of data frame(s) identifying a workable data dictionary structure.
dplyr::filter()
{
# use madshapR_DEMO provided by the package
# Create a list of data dictionaries where the column 'table' is added to
# refer to the associated dataset. The object created is not a
# data dictionary per say, but can be used as a structure which can be
# shaped into a data dictionary.
library(dplyr)
data_dict_list <- list(
data_dict_1 <- madshapR_DEMO$data_dict_TOKYO ,
data_dict_2 <- madshapR_DEMO$data_dict_MELBOURNE)
names(data_dict_list) = c("dataset_TOKYO","dataset_MELBOURNE")
data_dict_nest <- data_dict_list_nest(data_dict_list, name_group = 'table')
###### Example 1 search and filter through a column in 'Variables' element
data_dict_filter(data_dict_nest,filter_var = "valueType == 'text'")
###### Example 2 search and filter through a column in 'Categories' element
data_dict_filter(data_dict_nest,filter_cat = "missing == TRUE")
###### Example 3 search and filter through* a column in 'Variables' element.
# The column must exist in both 'Variables' and 'Categories' and have the
# same meaning
data_dict_filter(data_dict_nest,filter_all = "table == 'dataset_TOKYO'")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.