Learn R Programming

rapport (version 0.51)

rp.lineplot: Lineplot

Description

This function is a wrapper around xyplot with custom panel. Only numeric variables are accepted with optional facet.

Usage

rp.lineplot(x, y, facet = NULL, data = NULL,
    groups = NULL, ...)

Arguments

x
a numeric variable
y
a numeric variable
facet
an optional categorical variable to make facets by
groups
an optional categorical grouping variable
data
an optional data frame from which the variables should be taken
...
additional parameters to xyplot

Examples

Run this code
a <- aggregate(wt~gear, mtcars, mean)
rp.lineplot(a$gear, a$wt)
rp.lineplot(gear, wt, data=a)

## lame demo:
rp.lineplot(1:length(mtcars$hp), mtcars$hp, facet=mtcars$cyl)

## advanced usage
rp.lineplot(partner, age, data = rp.desc('age', 'partner', fn = 'mean', data=ius2008)) ## TODO: fix....
rp.lineplot(partner, age, gender, data = rp.desc('age', c('gender', 'partner'), fn = 'mean', data=ius2008))
rp.lineplot(partner, age, groups = gender, data=rp.desc('age', c('gender', 'partner'), fn = 'mean', data = ius2008))

## Did you noticed the nasty axis titles? Why not correct those? :)
df <- rp.desc('age', 'partner', fn = 'mean', data = ius2008)
lapply(names(df), function(x) rp.label(df[, x]) <<- x)   # nasty solution!
rp.lineplot(partner, age, data = df)
df <- rp.desc('age', c('gender', 'partner'), fn = 'mean', data = ius2008)
lapply(names(df), function(x) rp.label(df[, x]) <<- x)  # nasty solution!
rp.lineplot(partner, age, gender, data = df)
df <- rp.desc('age', c('gender', 'partner'), fn = 'mean', data = ius2008)
lapply(names(df), function(x) rp.label(df[, x]) <<- x)  # nasty solution!
rp.lineplot(partner, age, groups = gender, data = df)

Run the code above in your browser using DataLab