stCheckCovars: Check a data.frame of Covariates

Description Usage Arguments Value Author(s) See Also Examples

Description

Checks that data.frame of covariates is valid, making sure that all locations specified in ID.unique exist. The function will attempt to name each row in covars using 1) covars$ID, 2) rownames(covars), and 3) as.character(1:dim(covars)[1]). The field covars$ID is added if missing and rownames are removed.

Usage

1
stCheckCovars(covars, ID.unique = character(0))

Arguments

covars

data.frame containing covariates, to be checked.

ID.unique

vector with unique IDs that HAVE to be present in the covariates, typically the observation locations.

Value

Updated covars data.frame.

Author(s)

Johan Lindstrom

See Also

Other object checking utilities: stCheckClass, stCheckFields, stCheckObs, stCheckSTcovars

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
  ##load data
  data(mesa.model)

  ##check covariates
  tmp <- stCheckCovars( mesa.model$locations, mesa.model$locations$ID )
  str(tmp)
  ##require non-existant site
  try( stCheckCovars( mesa.model$locations, "Bad.Site" ) )
  ##drop the ID
  mesa.model$locations$ID <- NULL
  tmp <- stCheckCovars( mesa.model$locations )
  ##ID:s infered from rownames (1-25)
  str(tmp)

SpatioTemporal documentation built on May 2, 2019, 8:49 a.m.