View source: R/misc.utilities.R
compress_rows.data.frame | R Documentation |
compress_rows.data.frame
"compresses" a data frame, returning unique rows
and a tally of the number of times each row is repeated, as well as a
permutation vector that can reconstruct the original data frame.
decompress_rows.compressed_rows_df
reconstructs the original data frame.
## S3 method for class 'data.frame'
compress_rows(x, ...)
## S3 method for class 'compressed_rows_df'
decompress_rows(x, ...)
x |
For |
... |
Additional arguments, currently unused. |
For compress_rows.data.frame
, a list
with three
elements:
rows |
Unique rows of |
frequencies |
A vector of the same length as the number or rows, giving the number of times the corresponding row is repeated |
ordering |
A vector such that if
|
rownames |
Row
names of |
For decompress_rows.compressed_rows_df
, the original data frame.
data.frame
(x <- data.frame(V1=sample.int(3,30,replace=TRUE),
V2=sample.int(2,30,replace=TRUE),
V3=sample.int(4,30,replace=TRUE)))
(c <- compress_rows(x))
stopifnot(all(decompress_rows(c)==x))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.