group_age {microbiome} | R Documentation

## Age Classes

### Description

Cut age information to discrete factors.

### Usage

    group_age(
      x,
      breaks = "decades",
      n = 10,
      labels = NULL,
      include.lowest = TRUE,
      right = FALSE,
      dig.lab = 3,
      ordered_result = FALSE
    )

### Arguments

`x` | Numeric vector (age in years)
`breaks` | Class break points. Either a vector of breakpoints, or one of the predefined options ("years", "decades", "even").
`n` | Number of groups for the breaks = "even" option.
`labels` | labels for the levels of the resulting category. By default, labels are constructed using `"(a,b]"` interval notation. If `labels = FALSE`, simple integer codes are returned instead of a factor.
`include.lowest` | logical, indicating if an ‘x[i]’ equal to the lowest (or highest, for `right = FALSE`) ‘breaks’ value should be included.
`right` | logical, indicating if the intervals should be closed on the right (and open on the left) or vice versa.
`dig.lab` | integer which is used when labels are not given. It determines the number of digits used in formatting the break numbers.
`ordered_result` | logical: should the result be an ordered factor?

### Details

Regarding the breaks arguments, the "even" option aims to cut the samples in groups with approximately the same size (by quantiles). The "years" and "decades" options are self-explanatory.

### Value

Factor of age groups.

### Author(s)

Contact: Leo Lahti microbiome-admin@googlegroups.com

### References

See citation('microbiome')

### See Also

base::cut

### Examples

    data(atlas1006)
    age.numeric <- meta(atlas1006)$age
    age.factor <- group_age(age.numeric)

[Package microbiome version 1.14.0 Index]