compress: Compress or Expand Data Frames

View source: R/compress.R

compressR Documentation

Compress or Expand Data Frames

Description

Function to remove or restore redundant or empty elements from a data object.

Usage

compress(x, ...)

## S3 method for class 'data.frame'
compress(x, keep = "", na.rm = TRUE, remove = "", unique = FALSE, ...)

expand(x, ...)

## S3 method for class 'data.frame'
expand(x, keep, ...)

Arguments

x

Data object.

...

Not used.

keep

Data object.

na.rm

Logical value specifying whether to remove columns containing only NA values. columns containing only NA values.

remove

Character string(s) specifying other column contents to be treated as empty.

unique

Logical value specifying whether to remove columns that contain only a single unique value.

Methods (by class)

  • compress(data.frame): Remove empty data columns.

Examples

x <- data.frame(year = 2018, count = rpois(10, 5), survey = "scs", group = rep(1:2, each = 5))
x <- compress(x)
print(x)
attributes(x)
attr(x, "status") <- "critical"
expand(x)
attr(x, "units") <- c(length = "millimeters", weight = "grams")
expand(x)

TobieSurette/gulf.utils documentation built on Dec. 1, 2024, 6:01 a.m.