setaggre | R Documentation |
aggre
attributes to an object by modifying in placeCoerces 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.
setaggre(x, values = NULL, by = NULL, breaks = NULL)
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. |
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.
[data.table::setDT]
.
Returns x
invisibly after setting attributes to it without taking a copy.
This function is called for its side effects.
Joonas Miettinen
Other aggregation functions:
aggre()
,
as.aggre()
,
lexpand()
,
summary.aggre()
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.