OVERVIEW
The line chart is based on the standard R function plot
when called with only a single variable.
The values on the horizontal axis of the line chart are automatically generated. The default is the index variable, the ordinal position of each data value, in which case this version of the line chart is a run chart. Or, dates on the horizontal axis can be specified from the specified starting date given by x.start
and the accompanying increment as given by x.by
, in which case the line chart is typically referred to as a time series chart.
If the data values randomly vary about the mean, the default is to plot the mean as the center line of the graph, otherwise the default is to ignore the center line. The default plot type for the line chart is type="b"
, for both points and the corresponding connected line segments. The size of the points is automatically reduced according to the number of points of points plotted, and the cex
option can override the computed default. If the area below the plotted values is specified to be filled in with color, then the default line type changes to type="l"
.
DATA
The data may either be a vector from the global environment, the user's workspace, as illustrated in the examples below, or one or more variable's in a data frame, or a complete data frame. The default input data frame is mydata
. Can specify the source data frame name with the data
option. If multiple variables are specified, only the numerical variables in the list of variables are analyzed. The variables in the data frame are referenced directly by their names, that is, no need to invoke the standard R
mechanisms of the mydata$name
notation, the with
function or the attach
function. If the name of the vector in the global environment and of a variable in the input data frame are the same, the vector is analyzed.
COLORS
Individual colors in the plot can be manipulated with options such as stroke
. A color theme for all the colors can be chosen for a specific plot with the colors
option with the lessR
function style
. The default color theme is dodgerblue
, but a gray scale is available with "gray"
, and other themes are available as explained in style
, such as "red"
and "green"
. Use the option style(sub.theme="black")
for a black background and partial transparency of plotted colors.
For the color options, such as grid.stroke
, the value of "off"
is the same as "transparent"
.
VARIABLE LABELS
Although standard R does not provide for variable labels, lessR
does, obtained from the Read
function. If the variable labels exist, then the corresponding variable label is by default listed as the label for the horizontal axis and on the text output. For more information, see Read
.
PDF OUTPUT
To obtain pdf output, use the pdf
option, perhaps with the optional width
and height
options. These files are written to the default working directory, which can be explicitly specified with the R setwd
function.
ONLY VARIABLES ARE REFERENCED
The referenced variable in a lessR
function can only be a variable name (or list of variable names). This referenced variable must exist in either the referenced data frame, such as the default mydata
, or in the user's workspace, more formally called the global environment. That is, expressions cannot be directly evaluated. For example:
> LineChart(rnorm(50)) # does NOT work
Instead, do the following:
> Y <- rnorm(50) # create vector Y in user workspace
> LineChart(Y) # directly reference Y