group2: Groups counts based on range.

Description Usage Arguments Value Examples

Description

Created to count the number of people in a certain age range. Function tested using a data frame with continuous age values in one column, and counts of people in another column.

Usage

1
group2(x, group_of, FUN = "sum", age_labels = F)

Arguments

x

A dataframe

group_of

The range to group together.

FUN

A string of the function to be performed in the aggregate section. Default = "sum"

age_labels

Logical. If true, age labels are attempted. Only works if 1st age group starts at 0.

Value

A dataset that has been groupped by group_of and has had FUN perfomed on the grouping.

Examples

1
2
3
4
### Sum the number of men in each user defined age group
 # create data
 x <- data.frame(age = c(1:6), males = c(0,1,0,2,3,5), females = c(4,6,2,1,0,1))
 group2(x, 3, "sum")

matthew-phelps/grouping documentation built on May 21, 2019, 12:59 p.m.