Analyses the content of a dataset and its data dictionary (if any), identifies variable(s) data type and values accordingly and preprocess the variables. The elements of the data frame generated are evaluation of valid/non valid/empty values (based on the data dictionary information if provided). This function can be used to personalize report parameters and is internally used in the function dataset_summarize().

Generates a data frame that evaluates and aggregates all columns in a dataset with (if any) its data dictionary. The data dictionary (if present) separates observations between open values, empty values, categorical values , and categorical non-valid values (which corresponds to the 'missing' column in the 'Categories' sheet). This internal function is mainly used inside summary functions.

dataset_preprocess(
  dataset,
  data_dict = data_dict_extract(dataset),
  group_by = group_vars(dataset)
)

Arguments

dataset

A dataset object.

data_dict

A list of data frame(s) representing metadata of the input dataset. Automatically generated if not provided.

group_by

A character string identifying the column in the dataset to use as a grouping variable. Elements will be grouped by this column.

Value

A data frame providing summary elements of a dataset, including its values and data dictionary elements.

Details

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 dataset is a data table containing variables. A dataset object is a data frame and can be associated with a data dictionary. If no data dictionary is provided with a dataset, a minimum workable data dictionary will be generated as needed within relevant functions. Identifier variable(s) for indexing can be specified by the user. The id values must be non-missing and will be used in functions that require it. If no identifier variable is specified, indexing is handled automatically by the function.

Examples

{
 
# use madshapR_examples provided by the package
dataset <- madshapR_examples$`dataset_example`
head(dataset_preprocess(dataset))

}
#> $`(all)`
#> # A tibble: 450 × 19
#>    Index name_var `Variable name` valueType genericType `Variable class`
#>    <int> <chr>    <chr>           <chr>     <chr>       <chr>           
#>  1     1 part_id  part_id         text      character   no              
#>  2     1 part_id  part_id         text      character   no              
#>  3     1 part_id  part_id         text      character   no              
#>  4     1 part_id  part_id         text      character   no              
#>  5     1 part_id  part_id         text      character   no              
#>  6     1 part_id  part_id         text      character   no              
#>  7     1 part_id  part_id         text      character   no              
#>  8     1 part_id  part_id         text      character   no              
#>  9     1 part_id  part_id         text      character   no              
#> 10     1 part_id  part_id         text      character   no              
#> # ℹ 440 more rows
#> # ℹ 13 more variables: `Categorical variable` <chr>, index_value <int>,
#> #   `value_var long` <chr>, `value_var short` <chr>, value_var_occur <int>,
#> #   cat_index <dbl>, valid_class <chr>, name_palette <chr>,
#> #   `madshapR::group_occurrence` <dbl>, `madshapR::group_label long` <chr>,
#> #   `madshapR::group_label short` <chr>,
#> #   `Grouping variable: madshapR::no_group` <chr>, color_palette <chr>
#>