constant.data.frame {wrangle}R 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))))

[Package wrangle version 0.6.4 Index]