merge_df {lazy.tools}R Documentation

Horizontally Stack Data Frames with Different # of Observations

Description

Horizontally Stack Data Frames with Different # of Observations

Usage

merge_df(..., simplify = 1)

Arguments

...

vectors, matrices or data frames

simplify

= 0 not to convert the result to a matrix if possible.

Details

Using the data frames in the example section, the core part is:
res <- merge( data.frame(A1m,id=1:nrow(df1m)) , data.frame(A2m,id=(1:nrow(df2m))), by="id" ,all=1)


If simplify=1 is give, if possible, the result will be converted to a matrix.

Value

A data frame or matrix

Examples

# no overlapping col names
merge_df( x=1:2, y=1:5, z=1 )

# overlapping col names
A <- demomat(5,4,3,cnroot="V")
A1 <- A[,,1]; A2 <- A[,,2]; A3 <- A[,,3]
A1m <- A1[1:3,1,drop=0]; A2m <- A2[1:2,1:2]; A3m <- A3[1:3,1:3];
merge_df( A1m, A2m, A3m )


[Package lazy.tools version 0.1.6 ]