Description Usage Arguments Value See Also Examples
View source: R/LineChart-functions.R
This function is the primary interface to the LineChart package.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | lineChart(
formula,
data,
settings = NULL,
centralTendencyType = "mean",
errBarType = "SE",
title = "",
xlab = NULL,
ylab = NULL,
xlim = NULL,
ylim = NULL,
plotXAxis = TRUE,
plotYAxis = TRUE,
legendPosition = "CHOOSE_BEST",
legendTitle = "GROUP_NAME",
lwd.axes = par()$lwd,
add = FALSE,
xOrder = NULL,
replicate = NULL,
repFun = mean,
...
)
|
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 |
title |
The title to place at the top of the plot. |
xlab |
The label to place on the x-axis. If NULL (default), the name of the source of data for the x-variable will be used, if available. |
ylab |
The label to place on the y-axis. If NULL (default), the name of the source of data for the y-variable will be used if available. |
xlim |
The plotting range of the x-axis. |
ylim |
The plotting range of the y-axis. |
plotXAxis |
Should the x-axis be plotted? |
plotYAxis |
Should the y-axis be plotted? |
legendPosition |
The position at which the legend should be placed. If NULL, no legend is plotted. If "CHOOSE_BEST", the best legend position is selected. Otherise, it is passed through to legend() directly. |
legendTitle |
The title to be used in the legend box. If "GROUP_NAME" (default), the name of the source of data for the grouping variable will be used. If no legend title is desired, use |
lwd.axes |
The line width of the axes and box around the plotting area. |
add |
If FALSE, a new plot will be started and the data plotted in it. If TRUE, the data will be plotted in the current plotting device, if any. |
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 |
... |
Additional parameters, currently passed on to the legend creating functions. |
The plotting data frame that was used is returned invisibly. It contains all of the information used to create the plot.
createPlottingDf
, lineChartDf
, buildGroupSettings
, extractGroupSettings
, applySettingsToPlottingDf
, legendFromPlottingDf
, legendFromSettings
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | #Basic use case: Plotting data frame with default appearance.
data(ChickWeight)
lineChart(weight ~ Time * Diet, ChickWeight)
#You can modify the appearance of groups by providing group settings:
settings = buildGroupSettings(group=1:4, symbol=21:24, lty=1:4,
fillColor=gray(seq(0, 1, length.out = 4)))
lineChart(weight ~ Time * Diet, ChickWeight, settings=settings)
#Let's ignore group 3
settings[ settings$group == 3, "include" ] = FALSE
lineChart(weight ~ Time * Diet, ChickWeight, settings=settings)
#If for whatever reason you have data in two different data frames that you
#want in the same plot, use add=TRUE to add to the existing plot.
cw12 = ChickWeight[ ChickWeight$Diet %in% 1:2, ]
cw34 = ChickWeight[ ChickWeight$Diet %in% 3:4, ]
#Distinguish between the groups by fill color.
settings$fillColor = c("white", "white", "black", "black")
settings$include = TRUE #Include all groups
lineChart(weight ~ Time * Diet, cw12, legendPosition="topleft",
settings=settings, ylim=c(40,300))
lineChart(weight ~ Time * Diet, cw34, legendPosition="bottomright",
settings=settings, add=TRUE)
#The legend doesn't update, but another legend gets added.
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.