add_tercile_cat | R Documentation |
Given a data table with multiple years of data, this function derives the tercile category per year. It first derives terciles for the data and then returns, for each row, a -1 if the data falls into the lowest tercile, 0 if it falls between 1st and second tercile, and +1 if it falls above the third tercile. Allows grouping by levels (e.g. months and location-coordinates): Tercile categories are derived separately for each level.
add_tercile_cat(
dt,
datacol = NULL,
years = NULL,
by = setdiff(dimvars(dt), c("year", "member"))
)
dt |
the data table. |
datacol |
Name of the column where the data is stored. If NULL, the function guesses. |
years |
Optional, if provided only these years are used for establishing climatology terciles. |
by |
names of columns to group by. |
The provided data table with an extra column tercile_cat
dt = add_tercile_cat(chirps_monthly)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.