ssn_get_data {SSN2} | R Documentation |
Get a data.frame from an SSN, ssn_lm, or ssn_glm object
Description
The ssn_get_data
function extracts an
sf data.frame for the observation or prediction data from
an SSN
, ssn_lm
, or ssn_glm
object.
Usage
ssn_get_data(x, name = "obs")
Arguments
x |
An object of class |
name |
the internal name of the dataset in the object
|
Details
The internal name
for observed data in objects of
class SSN
is "obs" and it is the
default. If another name
is specified, it must represent a
prediction data set in the SSN
,
ssn_lm
, or ssn_glm
object. For SSN
objects,
these names are obtained using the call names(x$preds)
. For
all other object classes, the names are obtained using the call
names(x$ssn.object$preds)
.
Value
An sf data.frame
See Also
Examples
## Extract observed data from an SSN object
# Copy the mf04p .ssn data to a local directory and read it into R
# When modeling with your .ssn object, you will load it using the relevant
# path to the .ssn data on your machine
copy_lsn_to_temp()
temp_path <- paste0(tempdir(), "/MiddleFork04.ssn")
mf04p <- ssn_import(temp_path, predpts = "pred1km", overwrite = TRUE)
obs.df <- ssn_get_data(mf04p)
dim(obs.df)
## Extract prediction data from an SSN object
names(mf04p$preds)
pred1km.df <- ssn_get_data(mf04p, name = "pred1km")
names(pred1km.df)
## extract observed data from an ssn_lm object
ssn_mod <- ssn_lm(
formula = Summer_mn ~ ELEV_DEM,
ssn.object = mf04p,
tailup_type = "exponential",
additive = "afvArea"
)
obs.mod.df <- ssn_get_data(ssn_mod)
summary(obs.mod.df)
[Package SSN2 version 0.2.0 Index]