Learn R Programming

burnr (version 0.4.0)

count_event_position: Count of different events

Description

Count of different events

Usage

count_event_position(x, injury_event = FALSE, position, groupby)

Arguments

x

An fhx object.

injury_event

Optional boolean indicating whether injuries should be considered event. Default is FALSE.

position

Optional character vector giving the types of event positions to include in the count. Can any combination of the following: "unknown", "dormant", "early", "middle", "late", "latewd". The default counts all event positions.

groupby

Optional named list containing character vectors that are used to count the total number of different event types. The names given to each character vector give the group's name in the output data.frame.

Value

A data.frame with a columns giving the event and corresponding number of events for each event type.

Examples

Run this code
# NOT RUN {
data(pgm)
count_event_position(pgm)

# As above, but considering injuries to be a type of event.
count_event_position(pgm, injury_event = TRUE)

# Count only events of a certain position, in this case, "unknown", "early", and "middle".
count_event_position(pgm, injury_event = TRUE, position = c("unknown", "early", "middle"))

# Using custom `groupby` args.
grplist <- list(foo = c("dormant_fs", "early_fs"), bar = c("middle_fs", "late_fs"))
count_event_position(pgm, groupby = grplist)

# }

Run the code above in your browser using DataLab