getSSNdata.frame: Extract data from SSN objects as a data.frame

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/getSSNdata.frame.r

Description

The getSSNdata.frame function extracts the points data data.frame, either observation data or prediction data, from the specified SSN object.

Usage

1
getSSNdata.frame(x, Name = "Obs")

Arguments

x

an object of class SpatialStreamNetwork-class, influenceSSN-class, glmssn-class, or "glmssn.predict".

Name

the internal name of the data set in the object x. For observed values, this will always be "Obs", the default.

Details

The internal Name for observed data in objects of class SpatialStreamNetwork is "Obs" and it is the default. If another Name is specified, it must represent a prediction data set in the SpatialStreamNetwork-class, influenceSSN-class, glmssn-class, or "glmssn.predict" object. For SpatialStreamNetwork objects, these names are obtained using the call ssn@predpoints@ID. For all other object classes, the names are obtained using the call object$ssn.object@predpoints@ID. See examples for additional details.

Value

A data.frame.

Author(s)

Jay Ver Hoef support@SpatialStreamNetworks.com

See Also

putSSNdata.frame

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
library(SSN)
#for examples, copy MiddleFork04.ssn directory to R's temporary directory
copyLSN2temp()
# NOT RUN
# Create a SpatialStreamNetork object that also contains prediction sites
#mf04 <- importSSN(paste0(tempdir(),'/MiddleFork04.ssn', o.write = TRUE))
#use mf04 SpatialStreamNetwork object, already created
data(mf04)
#for examples only, make sure mf04p has the correct path
#if you use importSSN(), path will be correct
mf04 <- updatePath(mf04, paste0(tempdir(),'/MiddleFork04.ssn'))

obsDF <- getSSNdata.frame(mf04)
head(obsDF)

# get some model fits stored as data objects
data(modelFits)
#NOT RUN use this one
#fitSp <- glmssn(Summer_mn ~ ELEV_DEM + netID,
#    ssn.object = mf04p, EstMeth = "REML", family = "Gaussian",
#    CorModels = c("Exponential.tailup","Exponential.taildown",
#    "Exponential.Euclid"), addfunccol = "afvArea")
#for examples only, make sure fitSp has the correct path
#if you use importSSN(), path will be correct
fitSp$ssn.object <- updatePath(fitSp$ssn.object, 
	paste0(tempdir(),'/MiddleFork04.ssn'))

# Get the data.frame from an influenceSSN object and plot the residuals
fitSpRes <- residuals(fitSp)
fitSpResDF <- getSSNdata.frame(fitSpRes)
# NOT RUN
#plot(fitSpResDF[,"_resid.crossv_"],fitSpResDF[,"_resid_"], pch = 19,
#  ylab = "Cross-validation Residuals", xlab = "Raw Residuals")

# Get the data.frame for the prediction locations
fitSpPred <- predict(fitSp, predpointsID = "pred1km")
predNames<- fitSpPred$ssn.object@predpoints@ID
fitSpPredDF <- getSSNdata.frame(fitSpPred, predNames[1])
head(fitSpPredDF)

SSN documentation built on March 13, 2020, 1:49 a.m.