Generates a visual report of a dataset in an HTML bookdown document, with summary figures and statistics for each variable. The report outputs can be grouped by a categorical variable.

dataset_visualize(
  dataset = tibble(id = as.character()),
  bookdown_path,
  data_dict = data_dict_extract(dataset),
  group_by = attributes(dataset_summary)[["madshapR_group::group_by"]],
  valueType_guess = FALSE,
  taxonomy = NULL,
  dataset_summary = NULL,
  dataset_name = NULL
)

Arguments

dataset

A dataset object.

bookdown_path

A character string identifying the folder path where the bookdown report files will be saved.

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.

valueType_guess

Whether the output should include a more accurate valueType that could be applied to the dataset. FALSE by default.

taxonomy

An optional data frame identifying a variable classification schema.

dataset_summary

A list which identifies an existing summary produced by dataset_summarize() of the dataset. Using this parameter can save time in generating the visual report.

dataset_name

A character string specifying the name of the dataset (used internally in the function dossier_evaluate()).

Value

A folder containing files for the bookdown site. To open the bookdown site in a browser, open 'docs/index.html', or use bookdown_open() with the folder path.

Details

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.

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.

The valueType is a declared property of a variable that is required in certain functions to determine handling of the variables. Specifically, valueType refers to the OBiBa data type of a variable. The valueType is specified in a data dictionary in a column 'valueType' and can be associated with variables as attributes. Acceptable valueTypes include 'text', 'integer', 'decimal', 'boolean', datetime', 'date'. The full list of OBiBa valueType possibilities and their correspondence with R data types are available using valueType_list. The valueType can be used to coerce the variable to the corresponding data type.

A taxonomy is a classification schema that can be defined for variable attributes. A taxonomy is usually extracted from an Opal environment, and a taxonomy object is a data frame that must contain at least the columns taxonomy, vocabulary, and terms. Additional details about Opal taxonomies are available online.

Examples

# \donttest{

library(fs)
library(dplyr)
 
# use madshapR_examples provided by the package 
dataset <-
  madshapR_examples$`dataset_example` %>%
  group_by(gndr) %>%
  as_dataset(col_id = "part_id")
  
data_dict <- as_data_dict_mlstr(madshapR_examples$`data_dictionary_example`)
dataset <- data_dict_apply(dataset,data_dict)
dataset_summary <- dataset_summarize(dataset,data_dict)
#> - DATA DICTIONARY ASSESSMENT: data_dict --------------
#>     Assess the standard adequacy of naming
#>     Assess the uniqueness and presence of variable names
#>     Assess the presence of possible duplicated columns
#>     Assess the presence of duplicated rows
#>     Assess the presence of empty rows in the data dictionary
#>     Assess the presence of empty column in the data dictionary
#>     Assess the presence of categories not in the data dictionary
#>     Assess the `valueType` column in 'Variables'
#>     Assess the completion of `label:en` column in 'Variables'
#>     Assess presence and completion of `label:en` column in 'Categories'
#>     Assess the logical values of missing column in Categories
#>     Generate report
#> 
#>     The data dictionary contains no errors/warnings.
#> 
#>   - WARNING MESSAGES (if any): --------------------------------------------
#> 
#> - DATASET ASSESSMENT: dataset --------------------------
#>     Assess the standard adequacy of naming
#>     Assess the presence of variable names both in dataset and data dictionary
#>     Assess the presence of possible duplicated variable in the dataset
#>     Assess the presence of possible duplicated participants
#>     Assess the presence of unique value columns in dataset
#>     Assess the presence of empty rows in the dataset
#>     Assess the presence all empty variable in the dataset
#>     Assess the Categories comparison in dataset and data dictionary
#>     Assess the `valueType` comparison in dataset and data dictionary
#>     Generate report
#> 
#>   - WARNING MESSAGES (if any): -------------------------------------------------
#>     
#> - DATASET SUMMARIZE: dataset --------------------------
#>     Summarize the data type of each variable across the dataset
#>     Summarize information for all variables
#>     Summarize information for numerical variables
#>     Summarize information for text variables
#>     Summarize information for date variables
#>     Summarize information for categorical variables
#>     Summarize global information (Overview)
#>     Generate report
 
if(dir_exists(tempdir())) dir_delete(tempdir())
#> Error: [EBUSY] Failed to remove 'C:/Users/guill/AppData/Local/Temp/RtmpsjrqUz/Rf1c445d9a5fcd': resource busy or locked
bookdown_path <- tempdir()
 
dataset_visualize(
 dataset,
 data_dict,
 dataset_summary = dataset_summary,
 bookdown_path = bookdown_path)
#> Error: The path folder already exists. 
#> Please provide another name folder or delete the existing one.
  
# To open the file in browser, open 'bookdown_path/docs/index.html'. 
# Or use bookdown_open(bookdown_path) function.

# }