View source: R/S3_classes_demog_change_component_utility_functions.R
collapse_demog_dimension | R Documentation |
demog_change_component_df
object across demographic dimension(s)This function conveniently collapses objects across the demographic
dimension(s) specified in by_dimensions
. The “value”
column is aggregated using function FUN
. Columns
corresponding to by_dimensions
are dropped. If you want to
aggregate other columns, or complete collapsing over a dimension is
not desired, use aggregate
, or similar.
collapse_demog_dimension( x, FUN = "sum", ..., by_dimensions = demog_change_component_dims(x), collapse_dimensions = NULL, out_class = c("demog_change_component_df", "data.frame") )
x |
An object inheriting from
|
FUN |
A function to use to aggregate the “value” column
of |
... |
Passed to
|
by_dimensions |
A character vector (not a list) of demographic “dimensions” to aggregate over; see “Details”). |
out_class |
The class of the object to be returned
(specifically the first element of the vector returned by
|
Argument by_dimensions
is a character vector and can be any
of the allowed demographic “dimensions” such as
“age”, “time”, “sex” (you can see the full
list by calling ccmppWPP:::get_all_allowed_dimensions
). The
result will have values completely collapsed over the given
dimension. E.g., if by_dimensions = "age"
then column
value
in the result will contain the original value
s
aggregated over all remaining dimensions, where aggregation is done
by function FUN
.
A data frame.
Collapsing a demog_change_component_df
object will likely
make it an invalid member of its class. By default, the function
will attempt to return a
demog_change_component_df
. If this fails a
data.frame
will be returned with a warning.
Mark Wheldon
aggregate
, link{abridge}
demog_change_component_df
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.