constant.data.frame: Identify Constant Features of a Data Frame

View source: R/constant.R

constant.data.frameR Documentation

Identify Constant Features of a Data Frame

Description

Returns columns of a data.frame whose values do not vary within subsets defined by columns named in .... Defaults to groups(x) if none supplied, or all columns otherwise.

Usage

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

Arguments

x

object

...

optional grouping columns (named arguments are ignored)

Value

data.frame (should be same class as x)

See Also

Other constant: constant()

Examples

library(dplyr)
constant(Theoph)                      # data frame with 0 columns and 1 row
constant(Theoph, Subject)             # Subject Wt Dose Study
Theoph$Study <- 1
constant(Theoph)                      # Study
constant(Theoph, Study)               # Study
constant(Theoph, Study, Subject)      # Subject Wt Dose Study
Theoph <- group_by(Theoph, Subject)
constant(Theoph)                      # Subject Wt Dose Study
constant(Theoph, Study)               # Study
foo <- data.frame(x = 1)
foo <-  group_by(foo, x)
class(foo) <- c('foo', class(foo))
stopifnot(identical(class(foo), class(constant(foo))))

wrangle documentation built on May 29, 2024, 12:29 p.m.