View source: R/08-data_visualize.R
variable_visualize | R Documentation |
Analyses the content of a variable and its data dictionary (if any),
identifies its data type and values accordingly and generates figures and
summaries (datatable format). The figures and tables are representations of
data distribution, statistics and valid/non valid/missing values (based on
the data dictionary information if provided and the data type of the
variable). This function can be used to personalize report parameters and is
internally used in the function dataset_visualize()
. Up to seven objects
are generated which include : One datatable of the key elements of the
data dictionary, one datatable summarizing statistics (such as mean,
quartile, most seen value, most recent date, ... , depending on the
data type of the variable), two graphs showing the distribution of the
variable, One bar chart for categorical values (if any), One bar chart for
missing values (if any), One pie chart for the proportion of valid and
missing values (if any). The variable can be grouped using group_by
parameter, which is a (categorical) column in the dataset. The user may need
to use as_category()
in this context. To fasten the process (and allow
recycling object in a workflow) the user can feed the function with a
variable_summary
, which is the output of the function dataset_summarize()
of the column(s) col
and group_by
. The summary must have the same
parameters to operate.
variable_visualize(
dataset = tibble(id = as.character()),
col,
data_dict = NULL,
group_by = NULL,
valueType_guess = FALSE,
variable_summary = .summary_var,
.summary_var = NULL
)
dataset |
A dataset object. |
col |
A character string specifying the name of the column. |
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. |
variable_summary |
A summary list which is the summary of the variables. |
.summary_var |
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 list of up to seven elements (charts and figures and datatables) which can be used to summarize visualize data.
DT::datatable()
, ggplot2::ggplot()
dataset_summarize()
, dataset_visualize()
{
library(dplyr)
library(fs)
dataset <- madshapR_DEMO$dataset_TOKYO
variable_summary <- madshapR_DEMO$`dataset_summary`
variable_visualize(
dataset, col = 'height',
variable_summary = variable_summary,valueType_guess = TRUE)
variable_visualize(
dataset, col = 'height',
variable_summary = variable_summary,valueType_guess = TRUE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.