constant.data.frame | R Documentation |
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.
## S3 method for class 'data.frame'
constant(x, ...)
x |
object |
... |
optional grouping columns (named arguments are ignored) |
data.frame (should be same class as x)
Other constant:
constant()
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))))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.