View source: R/class-plotdata-box.R
box.dt | R Documentation |
This function returns a data.table of plot-ready data with one row per group (per panel). Columns 'x', 'min', 'q1', 'median', 'q3' and 'max' represent the pre-computed values per group. Columns 'group' and 'panel' specify the group the data belong to. Optionally, can return columns 'outliers' and 'mean' as well.
box.dt(
data,
variables,
points = c("outliers", "all", "none"),
mean = c(FALSE, TRUE),
computeStats = c(FALSE, TRUE),
overlayValues = NULL,
sampleSizes = c(TRUE, FALSE),
completeCases = c(TRUE, FALSE),
evilMode = c("noVariables", "allVariables", "strataVariables"),
verbose = c(TRUE, FALSE)
)
data |
data.frame to make plot-ready data for |
variables |
veupathUtils VariableMetadataList |
points |
character vector indicating which points to return 'outliers' or 'all' |
mean |
boolean indicating whether to return mean value per group (per panel) |
computeStats |
boolean indicating whether to compute nonparametric statistical tests (across x values or group values per panel) |
overlayValues |
veupathUtils::BinList providing overlay values of interest |
sampleSizes |
boolean indicating if sample sizes should be computed |
completeCases |
boolean indicating if complete cases should be computed |
evilMode |
String indicating how evil this plot is ('strataVariables', 'allVariables', 'noVariables') Metadata can include 'displayName', 'displayRangeMin', 'displayRangeMax', and 'collectionVariable'. Will be included as an attribute of the returned plot object. |
verbose |
boolean indicating if timed logging is desired |
data.table plot-ready data
An 'evilMode' exists. It will do the following:
- when ‘strataVariables' it will return ’no data' as a regular value for strata vars but will discard such cases for the axes vars.
- when ‘allVariables' it will return ’no data' as a regular value for all variables.
- when 'noVariables' it will do the sensible thing and return complete cases only.
- not return statsTables
- allow smoothed means and agg values etc over axes values where we have no data for the strata vars
- return a total count of plotted incomplete cases
- represent missingness poorly, conflate the stories of completeness and missingness, mislead you and steal your soul
# Construct example data
df <- data.table('entity.xvar' = sample(c('a','b','c'), 100, replace=T),
'entity.yvar' = rnorm(100),
'entity.overlay' = sample(c('red','green','blue'), 100, replace=T))
# Create VariableMetadataList that specifies variable role in the plot and supplies variable metadata
variables <- veupathUtils::VariableMetadataList(
veupathUtils::VariableMetadata(
variableClass = veupathUtils::VariableClass(value = 'native'),
variableSpec = veupathUtils::VariableSpec(variableId = 'xvar', entityId = 'entity'),
plotReference = veupathUtils::PlotReference(value = 'xAxis'),
dataType = veupathUtils::DataType(value = 'STRING'),
dataShape = veupathUtils::DataShape(value = 'CATEGORICAL')
),
veupathUtils::VariableMetadata(
variableClass = veupathUtils::VariableClass(value = 'native'),
variableSpec = veupathUtils::VariableSpec(variableId = 'overlay', entityId = 'entity'),
plotReference = veupathUtils::PlotReference(value = 'overlay'),
dataType = veupathUtils::DataType(value = 'STRING'),
dataShape = veupathUtils::DataShape(value = 'CATEGORICAL')
),
veupathUtils::VariableMetadata(
variableClass = veupathUtils::VariableClass(value = 'native'),
variableSpec = veupathUtils::VariableSpec(variableId = 'yvar', entityId = 'entity'),
plotReference = veupathUtils::PlotReference(value = 'yAxis'),
dataType = veupathUtils::DataType(value = 'NUMBER'),
dataShape = veupathUtils::DataShape(value = 'CONTINUOUS')
)
)
# Returns a data table with plot-ready data
dt <- box.dt(df, map, points = 'outliers', mean=F, computeStats=T)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.