Description Usage Arguments Details Value Author(s) References See Also Examples
The function merge items of a list.
1 | abmi.merge(x, na.rm = FALSE, drop=FALSE)
|
x |
a list with named vectors (or one column data frames) of its element. Vectors can be of different lengths. |
na.rm |
logical, should NAs removed from the result? |
drop |
logical, should unused factor levels be dropped? |
This function can be useful, when vecors are aimed to combined into the same data frame, but has different orderings and lengths. The function takes care to match names (using the union of all names found).
Result is coerced to data frame with colnames corresponding to names attribute of x
and rownames corresponding to union of names of elements of x
.
P\'eter S\'olymos, solymos@ualberta.ca
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 | ## A simple case to see how it works
a <- 1:20
a
names(a) <- paste("x", 1:20, sep="")
set.seed(123)
## Create subsets and reorder it
b <- a[order(sample(1:20,15))]
c <- a[order(sample(1:20,10))]
## A list with vectors to be merged
li <- list(a = a, b = b, c = c)
## Note the lengths
sapply(li, length)
abmi.merge(li)
## Note NA removel effect
abmi.merge(li, na.rm = TRUE)
## ABMI example
data(abmi.data)
abmi.li <- list(
nutr.moist = ithcase(abmi.data$sitecap[,9], abmi.data$sitecap$ABMI.Site),
tree.modif = ithcase(abmi.data$sitecap[,10], abmi.data$sitecap$ABMI.Site),
stru.stage = ithcase(abmi.data$sitecap[,11], abmi.data$sitecap$ABMI.Site))
x1 <- abmi.merge(abmi.li)
x1
x2 <- abmi.merge(abmi.li, na.rm = TRUE)
x2
dim(x1)
dim(x2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.