Learn R Programming

SpatioTemporal (version 1.1.2)

stCheckFields: Test if fields exist in an object.

Description

Test if named fields exist in name(x), if not the function fails with a suitable error message.

Usage

stCheckFields(x, what, name = "Object")

Arguments

x
Object to test.
what
A character vector naming that should occur in names(x).
name
Character string to be pasted into the error message describing x.

Value

  • Nothing

See Also

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

Examples

Run this code
##load data
  data(mesa.data)
  ##names present in dta
  names(mesa.data$covars)

  ##check for some names
  stCheckFields(mesa.data$covars, c("ID","x","lat"))
  ##check for non-existant names
  try( stCheckFields(mesa.data$covars, c("ID","x","test")) )

Run the code above in your browser using DataLab