ssn_put_data {SSN2} | R Documentation |
Put an sf data.frame in an SSN object
Description
The ssn_put_data
function puts an sf
data.frame representing observation or prediction
data into an SSN, ssn_lm, or ssn_glm object.
Usage
ssn_put_data(data, x, name = "obs", resize_data = FALSE)
Arguments
data |
sf data.frame with point geometry. |
x |
An object of class SSN, ssn_lm, or ssn_glm. |
name |
the internal name of the data set in the object
|
resize_data |
Logical. Indicates whether sf_df can have a different number of features than the current data.frame in the object. Default is FALSE. |
Details
The internal name
for observed data in objects of
class SSN
, ssn_lm
, and ssn_glm
is "obs" and it is the
default. If another name
is specified, it must represent a
prediction dataset in the 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).
The resize_sf_data
argument specifies whether sf_data can have a
different number of features (i.e., rows) than the sf data.frame
it is replacing. Care should be taken when resize_df is set to
TRUE, especially if the new sf_data has more features than the
existing sf data.frame. In these cases, the user is responsible
for ensuring that the additional features have the correct
spatial, topological, and attribute data to accurately represent
spatial relationships in the SSN object.
Value
Returns an object of the same class as x, which contains the sf data.frame sf_data.
See Also
Examples
data(mf04p)
## Extract observation data.frame from SSN object
obs.df <- ssn_get_data(mf04p)
## Create a new column for summer mean temperature and set Value in
obs.df$Value <- obs.df$Summer_mn
obs.df$Value[1] <- NA
## Put the modified sf data.frame into the SSN object
mf04p <- ssn_put_data(obs.df, mf04p)
head(ssn_get_data(mf04p)[, c("Summer_mn", "Value")])