setaggre {popEpi} | R Documentation |
Set aggre
attributes to an object by modifying in place
Description
Coerces an R object to an aggre
object, identifying
the object as one containing aggregated counts, person-years and other
information. setaggre
modifies in place without taking any copies.
Retains all other attributes.
Usage
setaggre(x, values = NULL, by = NULL, breaks = NULL)
Arguments
x |
a |
values |
a character string vector; the names of value variables |
by |
a character string vector; the names of variables by which
|
breaks |
a list of breaks, where each element is a breaks vector
as usually passed to e.g. |
Details
setaggre
sets x
to the aggre
class in place
without taking a copy as e.g. as.data.frame.XXX
functions do; see e.g.
setDT
.
Value
Returns 'x' invisibly after setting attributes to it without taking a copy. This function is called for its side effects.
Author(s)
Joonas Miettinen
See Also
Other aggregation functions:
aggre()
,
as.aggre()
,
lexpand()
,
summary.aggre()
Examples
df <- data.frame(sex = rep(c("male", "female"), each = 5),
obs = rpois(10, rep(7,5, each=5)),
pyrs = rpois(10, lambda = 10000))
## without any breaks
setaggre(df, values = c("obs", "pyrs"), by = "sex")
df <- data.frame(df)
df$FUT <- 0:4
## with breaks list
setaggre(df, values = c("obs", "pyrs"), by = "sex", breaks = list(FUT = 0:5))