d2ld {str2str} | R Documentation |
Data-Frame to List of Data-Frames
Description
d2ld
converts a data.frame to a list of data.frames. This is a simple call
to split.data.frame
splitting the data.frame up by groups.
Usage
d2ld(
d,
by,
keep.by = TRUE,
drop = FALSE,
sep = ".",
lex.order = FALSE,
check = TRUE
)
Arguments
d |
data.frame. |
by |
character vector of colnames specifying the groups to split the data.frame
up by. Can be multiple colnames, which implicitly calls |
keep.by |
logical vector of length 1 specifying whether the by columns should be kept in the list of data.frames (TRUE) or removed (FALSE). |
drop |
logical vector of length 1 specifying whether unused groups
from the |
sep |
character vector of length 1 specifying the string used to separate
the group names. Only applicable with multiple |
lex.order |
logical vector of length 1 specifying the order of the data.frames
in the list based on the groups in the |
check |
logical vector of length 1 specifying whether to check the structure
of the input arguments. For example, check whether |
Value
list of data.frames split by the groups specified in the by
columns.
The list names are the group names (with sep
if there are multiple
by
columns).
Examples
# one grouping variable
d2ld(d = mtcars, by = "vs")
d2ld(d = mtcars, by = "gear")
# two grouping variables
d2ld(d = mtcars, by = c("vs","gear"))
d2ld(d = mtcars, by = c("vs","gear"), lex.order = TRUE)
# keep.by argument
d2ld(d = mtcars, by = "vs", keep.by = FALSE)
d2ld(d = mtcars, by = "gear", keep.by = FALSE)
d2ld(d = mtcars, by = c("vs","gear"), keep.by = FALSE)