select_factor_count_strictly_positive: Select data based on the number of presences per category

View source: R/select_factor_count_strictly_positive.R

select_factor_count_strictly_positiveR Documentation

Select data based on the number of presences per category

Description

Presences have Count > 0.

Usage

select_factor_count_strictly_positive(
  observation,
  variable,
  threshold,
  relative = FALSE,
  dimension = 1
)

Arguments

observation

the data.frame with observations

variable

the name of the factor

threshold

the minimal threshold

relative

When FALSE the threshold is the number of non-zero observations. When TRUE the threshold is the proportion of non-zero observations. Defaults to FALSE.

dimension

Indicates which element of variable is used for the final aggregation.

Examples

observation <- data.frame(
  Count = c(4, 4, 4, 4, 3, 3, 3, 0, 2, 2, 0, 0),
  LocationID = rep(1:3, each = 4),
  Year = rep(c(1, 1, 1, 1, 2, 2), 2)
)
# Select the locations with at least 3 prescenses
select_factor_count_strictly_positive(
  observation,
  variable = "LocationID",
  threshold = 3
)
# Select those locations in which the species is present in at least 2 years
select_factor_count_strictly_positive(
  observation, variable = c("LocationID", "Year"), threshold = 2
)
# Select those years in which the species is present in at least 2 locations
select_factor_count_strictly_positive(
  observation, variable = c("LocationID", "Year"),
  threshold = 2,
  dimension = 2
)

INBO-Natura2000/n2kanalysis documentation built on Feb. 15, 2024, 11:24 a.m.