multisplit | R Documentation |
A data frame is split into a list of data subsets defined by multiple groups.
multisplit(data, grouping, drop = TRUE, sep = ":", ...) ## S4 method for signature 'data.frame,formula' multisplit(data, grouping, drop = TRUE, sep = ":", ...) ## S4 method for signature 'data.frame,character' multisplit(data, grouping, drop = TRUE, sep = ":", ...) ## S4 method for signature 'data.frame,factor' multisplit(data, grouping, drop = TRUE, sep = ":", ...) ## S4 method for signature 'data.frame,list' multisplit(data, grouping, drop = TRUE, sep = ":", ...) ## S4 method for signature 'ANY,ANY' multisplit(data, grouping, drop = TRUE, sep = ":", ...)
data |
data frame, matrix or vector containing several subsets of data |
grouping |
either a character vector containing the names of the grouping variables
or a model formula specifying dependent,
independent and grouping variables in the form:
|
drop |
if drop is TRUE, unused factor levels are dropped from the result. The default is to drop all factor levels. |
sep |
string to construct the new level labels by joining the constituent ones. |
... |
other parameters passed to |
This function is wrapper around split
with
different defaults, slightly different behavior, and methods for additional
argument classes. multisplit
returns always a data frame.
list containing data frames of the data subsets as its elements. The components of the list are named by their grouping levels.
split
data(bactgrowth) ## simple method spl <- multisplit(bactgrowth, c("strain", "conc", "replicate")) ## preferred method spl <- multisplit(bactgrowth, value ~ time | strain + conc + replicate) ## show what is in one data set spl[[1]] summary(spl[[1]]) ## use factor combination spl[["D:0:1"]] summary(spl[["D:0:1"]]) lapply(spl, FUN=function(x) plot(x$time, x$value, main=paste(x[1, "strain"], x[1, "conc"], x[1, "replicate"], sep=":")))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.