stackdata {geoBayes} | R Documentation |
Combine data.frame
s
Description
Combine data.frame
s
Usage
stackdata(..., fillwith = NA, keepclass = FALSE)
Arguments
... |
|
fillwith |
Which value to use for missing variables. This could be a scalar, a named vector, or a named list with one value in each component; see Details. |
keepclass |
Whether to preserve the |
Details
This function combines data.frame
s by filling in missing
variables. This is useful for combining data from
sampled locations with prediction locations.
If fillwith
is a named object, its names must correspond to
the names of variables in the data frames. If a variable is
missing, then it is filled with the corresponding value in
fillwith
. fillwith
can contain only one unnamed
component which corresponds to the default filling.
Value
A stacked data.frame
.
Examples
## Not run:
d1 <- data.frame(w = 1:3, z = 4:6 + 0.1)
d2 <- data.frame(w = 3:7, x = 1:5, y = 6:10)
(d12a <- stackdata(d1, d2))
lapply(d12a, class)
(d12b <- stackdata(d1, d2, fillwith = c(x = NA, y = 0, z = -99)))
lapply(d12b, class)
(d12c <- stackdata(d1, d2, fillwith = c(x = NA, y = 0, z = -99),
keepclass = TRUE))
lapply(d12c, class)
(d12d <- stackdata(d1, d2, fillwith = c(x = NA, 0)))
data(rhizoctonia)
predgrid <- mkpredgrid2d(rhizoctonia[c("Xcoord", "Ycoord")],
par.x = 100, chull = TRUE, exf = 1.2)
rhizdata <- stackdata(rhizoctonia, predgrid$grid)
## End(Not run)