checkDat {plantTracker}R Documentation

checkDat

Description

A function that both checks and prepares a data.frame for use in the trackSpp function.

Usage

checkDat(
  dat,
  inv = NULL,
  species = "Species",
  site = "Site",
  quad = "Quad",
  year = "Year",
  geometry = "geometry",
  reformatDat = FALSE,
  ...
)

Arguments

dat

An sf data.frame of the same format as grasslandData. It must have columns that contain...

  • a unique identification for each research site in character format with no NAs (the default column name is "Site")

  • species name in character format with no NAs (the default column name is "Species")

  • unique quadrat identifier in character format with no NAs (the default column name is "Quad")

  • year of data collection in integer format with no NAs (the default column name is "Year")

  • an s.f 'geometry' column that contains a polygon or multipolygon data type for each individual observation (the default column name is "geometry")

inv

The name of each element of the list is a quadrat name in 'dat', and the contents of that list element is a numeric vector of all of the years in which that quadrat (or other unique spatial area) was sampled. Make sure this is the years the quadrat was actually sampled, not just the years that have data in the 'dat' argument! This argument allows the function to differentiate between years when the quadrat wasn't sampled and years when there just weren't any individuals of a species present in that quadrat.

species

An optional character string argument. Indicates the name of the column in 'dat' that contains species name data. It is unnecessary to include a value for this argument if the column name is "Species" (default value is 'Species').

site

An optional character string argument. Indicates the name of the column in 'dat' that contains site name data. It is unnecessary to include a value for this argument if the column name is "Site" (default value is 'Site').

quad

An optional character string argument. Indicates the name of the column in 'dat' that contains quadrat name data. It is unnecessary to include a value for this argument if the column name is "Quad" (default is 'Quad').

year

An optional character string argument. Indicates the name of the column in 'dat' that contains data for year of sampling. It is unnecessary to include a value for this argument if the column name is "Year" (default is 'Year').

geometry

An optional character string argument. Indicates the name of the column in 'dat' that contains sf geometry data. It is unnecessary to include a value for this argument if the column name is "geometry" (default is 'geometry').

reformatDat

A TRUE/FALSE argument. If 'FALSE', which is the default value, then checkDat() prints a message that says the 'dat' and 'inv' datasets are ready for use in the trackSpp() function. This message includes any column name arguments that must be included in the trackSpp() function call for these datasets. If 'TRUE', checkDat() returns a list with three elements: a version of 'dat' that has been checked for errors and is ready to be input directly into the trackSpp or assign functions, a version of 'inv' that is checked and ready for input into trackSpp() or assign(), and a character vector called 'userColNames' that has all of the user-defined column names that were used in the original version of 'dat'.

...

Other arguments passed on to methods. Not currently used.

Details

This function is used internally in trackSpp and other plantTracker functions to check the 'dat' and 'inv' arguments and ensure that they are in the correct format with the correct column names. checkDat() can also be used independently to check that a data.frame is in the correct format and contains the correct data to be used in the trackSpp() or other plantTracker functions.

Value

If the 'reformatDat' argument is FALSE (the default), the return of this function is a message that says the 'dat' and 'inv' datasets are ready for use in the trackSpp() function. This message includes any column name arguments that must be included in the trackSpp() function call for these datasets. If the 'reformatDat' argument is TRUE, then checkDat() returns a list that contains versions of 'dat' and 'inv' that are ready to go directly into the trackSpp() or assign() functions. The list has the following elements:

dat

An sf data.frame that has five columns called 'Species', 'Site', 'Quad', 'Year', and 'geometry'. Any additional columns that were present in the version of 'dat' input into the checkDat() function will also be included in this version, although the column names will be appended with "_USER".

inv

A named list. The name of each element of the list is a quadrat name in 'dat', and the contents of that list element is a numeric vector of all of the years in which that quadrat (or other unique spatial area) was sampled. For each list element, the vector of years is in sequential order from oldest to most recent.

userColNames

A named character vector. This vector contains the column names provided by the user for all of the required data columns in the original version of 'dat'. The name of each vector element indicates the type of data that is contained in the column with the name in that vector element. For example, if the 'dat' data.frame input into checkDat() has the names 'Species','location' 'quadrat', 'Year', and 'geometry', then this list element will be a character vector of these values with the names 'species', 'site', 'quad', 'year', and 'geometry'.

Examples

checkDat(dat = grasslandData,
inv = grasslandInventory)

checkDat(dat = grasslandData,
inv = grasslandInventory,
reformatDat = TRUE)


[Package plantTracker version 1.1.0 Index]