Description Usage Arguments Details Value Examples
View source: R/LineChart-functions.R
This function creates a data frame that can be used for plotting
from a user-supplied data frame. The user data will be aggregated
based on the formula. The resulting plotting data frame can be used
with lineChartDf
.
1 2 3 4 5 6 7 8 9 10 |
formula |
The formula should be of the form |
data |
A data frame containing the data to be used in creation of the plotting data frame. |
settings |
Plotting settings for the different groups in the data, such as the symbol to use. |
centralTendencyType |
Character or function. The type of central tendency measure to use. Can be "mean" or "median". If a function, should be a function of one vector argument that returns a scalar. |
errBarType |
The type of error bar to use. Can be "SE" for standard error, "SD" for standard deviation, "CI95" for a 95% confidence interval, or "Cred95" for 95% credible interval. If |
xOrder |
The order in which to plot the x variable. A character vector containing all of the levels of the x variable in the order in which they should be plotted. If the |
replicate |
The name of a column in |
repFun |
A function that is used to aggregate values for each replicate. Defaults to |
Note that if no grouping variables are supplied by the formula, a group
column
will still be made in the resulting data frame and the group name will be the number 0.
A data.frame
which can be plotted with lineChartDf
. See the documentation for lineChartDf for examples.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | data(ChickWeight)
#Example of a user-defined central tendency function:
trimmedMedian = function(x) {
#trim highest and lowest values
x = sort(x)[ 2:(length(x) - 1) ]
median(x)
}
#Example of a user-defined error bar function:
quartiles = function(x) {
qs = as.numeric(quantile(x, c(0.25, 0.75)))
list(eb=qs, includesCenter=TRUE)
}
plotDf = createPlottingDf(weight ~ Time * Diet, ChickWeight,
centralTendencyType=trimmedMedian, errBarType=quartiles)
lineChartDf(plotDf)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.