Description Usage Arguments Details Value Warning Examples
Collapse unchanging consecutive observations for a given data frame.
1 |
data |
A data.frame. Data to collapse |
include_na |
Boolean. Whether to collapse consecutive NAs. |
If the given data frame contains multiple columns, then an observation is only collapsed if all of the columns are unchanging.
1 2 | Row and column names will be preserved; however, other
user defined attributes will be dropped.
|
A data.frame
of row size: 0 < N <= nrow(data)
.
collapse
currently only works with REALSXP,
INTSXP, STRSXP, LGLSXP objects. This covers all of the
common atomic R data types, including more complex types
like Date
. Unfortunately however, this means that
collapse
will return an error if a column has a class
of raw
. Bummer.
1 2 3 4 5 | x <- data.frame(x = c(1, 1, 1), y = c(1, 2, 2))
collapse(x)
y <- data.frame(x = c(1, 1, 1), y = c("a", "a", "b"), stringsAsFactors = FALSE)
collapse(y)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.