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
|
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 |
... |
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 |
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 |
Examples
checkDat(dat = grasslandData,
inv = grasslandInventory)
checkDat(dat = grasslandData,
inv = grasslandInventory,
reformatDat = TRUE)