View source: R/class-plotdata-scatter.R
scattergl | R Documentation |
This function returns the name of a json file containing plot-ready data with one row per group (per panel). Columns 'seriesX' and 'seriesY' contain the raw data for the scatter plot. Column 'group' and 'panel' specify the group the series data belongs to. Optionally, columns 'smoothedMeanX', 'smoothedMeanY' and 'smoothedMeanSE' specify the x, y and standard error respectively of the smoothed conditional mean for the group. Columns 'densityX' and 'densityY' contain the calculated kernel density estimates. Column 'seriesGradientColorscale' contains values to be used with a gradient colorscale when plotting.
scattergl(
data,
variables,
value = c("smoothedMean", "smoothedMeanWithRaw", "bestFitLineWithRaw", "density",
"raw"),
overlayValues = NULL,
correlationMethod = c("none", "pearson", "sparcc", "spearman"),
sampleSizes = c(TRUE, FALSE),
completeCases = c(TRUE, FALSE),
evilMode = c("noVariables", "allVariables", "strataVariables"),
idColumn = NULL,
returnPointIds = c(FALSE, TRUE),
verbose = c(TRUE, FALSE)
)
data |
data.frame to make plot-ready data for |
variables |
veupathUtil::VariableMetadataList and its position in the plot. Recognized plotRef values are 'xAxisVariable', 'yAxisVariable', 'overlayVariable', 'facetVariable1' and 'facetVariable2' |
value |
character indicating whether to calculate 'smoothedMean', 'bestFitLineWithRaw' or 'density' estimates (no raw data returned), alternatively 'smoothedMeanWithRaw' to include raw data with smoothed mean. Note only 'raw' is compatible with a continuous overlay variable. |
overlayValues |
veupathUtils::BinList providing overlay values of interest |
correlationMethod |
character indicating which correlation method to use. One of 'pearson', 'spearman','sparcc' or 'none'. Default is 'none'. |
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') |
idColumn |
character indicating the column name of the id variable in data |
returnPointIds |
boolean indicating if any point ids should be returned with the scatterplot data. |
verbose |
boolean indicating if timed logging is desired |
character name of json file containing 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' = rnorm(100),
'entity.yvar' = rnorm(100),
'entity.overlay' = sample(c('red','green','blue'), 100, replace=T), stringsAsFactors = F)
# 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 = 'NUMBER'),
dataShape = veupathUtils::DataShape(value = 'CONTINUOUS')
),
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 the name of a json file
scattergl(df, map, value = 'bestFitLineWithRaw')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.