Description Usage Arguments Details Value See Also Examples
rbinds a list of Matrix or matrix like objects, filling in missing columns.
1 | rBind.fill(x, ..., fill = NULL, out.class = class(rbind(x, x))[1])
|
x, ... |
Objects to combine. If the first argument is a list and
|
fill |
value with which to fill unmatched columns |
out.class |
the class of the output object. Defaults to the class of x. Note that some output classes are not possible due to R coercion capabilities, such as converting a character matrix to a Matrix. |
Similar to rbind.fill.matrix
, but works for
Matrix
as well as all other R objects. It is completely
agnostic to class, and will produce an object of the class of the first input
(or of class matrix
if the first object is one dimensional).
The implementation is recursive, so it can handle an arbitrary number of inputs, albeit inefficiently for large numbers of inputs.
This method is still experimental, but should work in most cases. If the
data sets consist solely of data frames, rbind.fill
is
preferred.
a single object of the same class as the first input, or of class
matrix
if the first object is one dimensional
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | df1 = data.frame(x = c(1,2,3), y = c(4,5,6))
rownames(df1) = c("a", "b", "c")
df2 = data.frame(x = c(7,8), z = c(9,10))
rownames(df2) = c("a", "d")
rBind.fill(df1,df2,fill=NA)
rBind.fill(as(df1,'Matrix'),df2,fill=0)
rBind.fill(as.matrix(df1),as(df2,'Matrix'),c(1,2),fill=0)
rBind.fill(c(1,2,3),list(4,5,6,7))
rBind.fill(df1,c(1,2,3,4))
m<-rsparsematrix(1000000,100,.001)
m2<-m
colnames(m)<-1:100
colnames(m2)<-3:102
system.time(b<-rBind.fill(m,m2))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.