A mixed-count observation is one record where the observer described a
group of individuals and gave the number of each kind by sex, life stage
or activity (for example 10 males and 7 females). Those rows have
is_multiple = TRUE and a details cell such as "10 Male; 7 Female".
Arguments
- x
An
obs_read()result.
Value
An obs_df. nrow() may be larger than the number of
observations.
Details
obs_expand() replaces each mixed-count row by one row per sex / life
stage / activity line. Other columns (species, place, validation,
coordinates) are copied. Use this before counting individuals with
sum(number) by sex or life_stage.
The extra rows come from a small table stored when the SQLite file is
read (observation_details). Nothing is duplicated until you call this
function. Maps should keep the compact table so each observation stays
one point. CSV and Excel have no breakdown, so they are returned as-is.
After dplyr::select(), keep id (and lat / lng for maps).
obs_summary() and obs_plot() for sex, life stage and activity already
expand internally.
Examples
obs <- obs_read(obs_example_db())
expanded <- obs_expand(obs)
tapply(expanded$number, expanded$sex, sum)
#> Female Male Unspecified
#> 67 136 20287