grab | R Documentation |
The grab
functions allow you to select nodes of the tree for further
investigation and summary. Once a node is selected, a map of the points is shown
with highlighted points of the selection along with a barplot of the prey
distribution found at that node. When applied to an object of class bag
,
bagged distributions of prey are shown. The grabmulti
function produces
multiple summaries on successive nodes selected by the user.
grab(object, LatID, LonID, setID = NULL, node.cols = NULL, cex = 0.8,
mapxlim = NULL, mapylim = NULL, database = "world",
display.object = NULL, oob = FALSE, n = NULL, ylimit)
## S3 method for class 'dpart'
grab(object, LatID, LonID, setID = NULL,
node.cols = NULL, cex = 0.8, mapxlim = NULL, mapylim = NULL,
database = "world", display.object = NULL, oob = FALSE, n = NULL,
ylimit = NULL)
## S3 method for class 'bag'
grab(object, LatID, LonID, setID = NULL,
node.cols = NULL, cex = 0.8, mapxlim = NULL, mapylim = NULL,
database = "world", display.object, oob = FALSE, n = NULL, ylimit)
## S3 method for class 'dpart'
grabmulti(object, LatID, LonID, setID = NULL,
node.cols = NULL, cex = 0.8, mapxlim = NULL, mapylim = NULL,
n = nrow(object$frame), database = "world")
grabmulti(object, LatID, LonID, setID = NULL, node.cols = NULL,
cex = 0.8, mapxlim = NULL, mapylim = NULL,
n = nrow(object$frame), database = "world")
object |
tree object either of class |
LatID |
string. Column name of latitude. |
LonID |
string. Column name of longitude. |
setID |
optional set identification number. |
node.cols |
vector of node colours assigned to each prey.
Use output from |
cex |
numeric. Size of plotting symbols and labels (default: 0.8) |
mapxlim |
optional map x-limits. If none are specified then the range of the data are used. |
mapylim |
optional map y-limits. If none are specified then the range of the data are used. |
database |
either 'world' or 'world2' are available for plotting. Defaults to 'world' if not specified. |
display.object |
tree object to display. This may be different
to |
oob |
logical. Option when a bagged tree is passed to the
|
n |
numeric. Maximum number of nodes to investigate in the tree. Defaults to the number in the tree. |
ylimit |
y-axis limit for barcharts that are produced by the
|
The grab.dpart
function can be used on any
tree object of class dpart
.
The grab.bag
function can be used on any tree
object of class bag
.
The grabmulti.dpart
function can only be used on
tree objects of class dpart
.
These functions can be invoked explicitly or just by
calling the grab
and grabmulti
functions.
Summary output from the node/s selected in the tree consisting of the node number, number of observations, number of sets (if the setID was provided), number of predators, number of prey, deviance, expected loss and predicted class.
Kuhnert, P.M., Duffy, L. M and Olson, R.J. (2012) The Analysis of Predator Diet and Stable Isotope Data, Journal of Statistical Software, In Prep.
plot.dpart
; bagging
# Assigning prey colours for default palette
val <- apc(x = yftdiet, preyfile = PreyTaxonSort, check = TRUE)
node.colsY <- val$cols
dietPP <- val$x # updated diet matrix with Group assigned prey taxa codes
# Fitting the classification tree
yft.dp <- dpart(Group ~ Lat + Lon + Year + Quarter + SST + Length,
data = dietPP, weights = W, minsplit = 10,
cp = 0.001)
# Pruning the tree
yft.pr <- prune(yft.dp, se = 1)
# Exploring Nodes: This suite of graphics is interactive and therefore has
# been commented out. When run, the code will ask you to select a node for
# viewing.
## Not run:
# Exploring nodes of the tree - single page
val <- grab(object = yft.pr, LatID = "Lat", LonID = "Lon", setID = "TripSetNo",
node.cols = node.colsY, cex = 1, mapxlim = c(-125, -75), mapylim = c(0, 30))
# Exploring nodes of the tree - multiple pages
val <- grab(object = yft.pr, LatID = "Lat", LonID = "Lon", setID = "TripSetNo",
node.cols = node.colsY, cex = 1, mapxlim = c(-125, -75), mapylim = c(0, 30))
# Exploring multiple nodes
grabmulti(object = yft.pr, LatID = "Lat", LonID = "Lon", setID = "TripSetNo",
node.cols = node.colsY, cex = 0.8, mapxlim = c(-125, -75), mapylim = c(0, 30))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.