RL_subset_seasons: Subset to species-season combinations

Description Usage Arguments Details Value Author(s)

View source: R/RL_subset_seasons.R

Description

Subset wide format data to species-season combinations. Also allows copying of data for missing desired seasons.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
RL_subset_seasons(
  x,
  season_df,
  query,
  species.col.name = NA,
  season.col.name = NA,
  fill.missing.seasons = NA,
  retain.na.seasons = FALSE,
  retain.missing.sp = TRUE
)

Arguments

x

A wide format dataframe with one column per habitat category. As output by RL_fetch().

season_df

A dataframe consisting of a column for species and a column for season. A species with multiple seasons desired should have one row per season. See Details.

query

Character. Are species represented by names ("name") or IUCN IDs ("ID")?

species.col.name

(optional) Character. What column name of season_df are the species names/IDs found in. Defaults to the first column of the dataframe.

season.col.name

(optional) Character. What column name of season_df are the seasons found in. Defaults to the second column of the dataframe.

fill.missing.seasons

(optional) Vector. If seasons are present in season_df but not on the Red List, should data be copied from seasons which are present and if so which? Acceptable values are season codes - see seasons. Defaults to NA (no copying).

retain.na.seasons

(optional) Logical. Some seasons are coded as NA on the Red List. RL_fetch() pulls these down as 999. Would you like to retain these seasons? Defaults to FALSE.

retain.missing.sp

(optional) Logical. If a species is not found in season_df, should it be retained? Defaults to TRUE.

Details

season_df should have seasons coded numerically as per redlistManipulatr::seasons$Code.

If the data for a season doesn't exist on the RedList (e.g. a bird may have breeding season and non-breeding season data but no data for resident), then fill.missing.seasons lets you say which seasons you want to copy data from. This can include any of the Red List season codes - for instance fill.missing.seasons = c(1,2,5) would mean that for a season we're missing data for, we look at the data (if it exists) for the resident, breeding season, and seasonal occurrence uncertain seasons and select the most suitable combination - e.g. if resident has habitat 1.2 as suitable major importance Yes and breeding season has it as marginal major importance No then we take the value from resident because it has a higher suitability.

Value

A dataframe in wide format (one column per habitat type).

Author(s)

Matt Lewis, matthewlewis896@gmail.com


matthewlewis896/redlistManipulatr documentation built on Jan. 22, 2022, 1:01 p.m.