Description Usage Arguments Examples
A simple utility method for visualizing a list of data groups.
1 2 | batchPlot.groups(data, extract = identity,
colors = colors.distinct(length(data)), ...)
|
data |
the data object, could be a list of lists or anything |
extract |
a function which extracts a list of data elements from each
element of |
colors |
the colors to be used for the plot |
... |
Arguments passed on to
|
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 28 29 30 31 32 33 34 35 36 37 38 39 | library(plotteR)
# set a random seed for replicability
set.seed(2677);
# the three base functions with the mean parameter values
f <- list(
list(f=function(x, par) par[1] + par[2]*x + par[3]*x*x + par[4]*x*x*x,
m=c(1, -0.2, 0.75, -0.3)),
list(f = function(x, par) par[1] * exp(par[2] - x),
m=c(0.1, 3)),
list(f=function(x, par) par[1] + par[2]*sin(par[3]*x),
m=c(0, 1, 3)));
# create the three example data sets
examples <- lapply(X=f, FUN=function(example) {
# for each example function, plot 4 to 50 instances
lapply(seq_len(runif(n=1, min=4, max=50)),
# for each instance
FUN=function(i) {
# randomly choose the x-coordinates
x <- runif(n=as.integer(round(runif(n=1, min=10, max=200))),
min=0, max=3);
m <- example$m;
# pick parameters which are normally distributed around the suggestion
par <- rnorm(n=length(m), mean=m, s=0.1*abs(m));
# and construct a function
fff <- function(x) example$f(x, par);
# and pass this function as result example together with the x values
list(x=x, f=fff)
})
});
# plot the original data
batchPlot.groups(examples,
names=c("f1", "f2", "f3"),
main="Several Groups of Functions",
plotXY=FALSE, plotXF=TRUE,
legend=list(x="bottom", horiz=TRUE));
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.