createVisits: Create unique visits IDs

View source: R/organizeBirds.R

createVisitsR Documentation

Create unique visits IDs

Description

Takes a data.frame and a vector of column names and classifies each row of the data.frame based on the combination of values in the specified columns.

Usage

createVisits(
  x,
  idCols = c("locality", "recordedBy"),
  timeCols = c("day", "month", "year"),
  grid = NULL,
  gridIdCol
)

Arguments

x

An object of class data.frame, sf or SpatialPointsDataFrame including at least the columns specified that are used to identify a visit.

idCols

A vector with the names of the columns other (than time columns) that are used to identify a visit. This variable cannot be empty. At least the recorders name or any other ID must be provided. Default is the Darwin Core variables c("locality", "recordedBy").

timeCols

A vector with the names of the time columns that are used to identify a visit. If timeCols=NULL then time is ignored to create a visit ID. Default is the Darwin Core variables c("day", "month", "year").

grid

Either NULL to be ignored or an object of class sf, SpatialPolygons or SpatialPolygonsDataFrame defining the maximum extent of visits effort. Then x must be an object of class sf

gridIdCol

column in grid with ids.

Details

What a visit should be is not always clearly defined and extractable in a dataset. A reasonable assumption is that a visit could be identified from the records made by one person on a certain day and at a specific location or site. The default value for the variable column is therefore that a visit is identified by the Darwin Core variables c("locality", "day", "month", "year", "recordedBy").

Value

A vector of the same length as the number of rows as the data.frame with a unique number for each combination of the values in the specified columns.

Examples

OB <- organizeBirds(bombusObs)
tmp.vis <- createVisits(bombusObs,
                        idCols=c("locality", "recordedBy"),
                        timeCols=c("day", "month", "year"),
                        gridIdCol = "id")
visits(OB, name = "visNoRecorder", useAsDefault = TRUE) <- tmp.vis

Greensway/BIRDS documentation built on Oct. 19, 2023, 2:35 a.m.