[R] Aggregate over multiple and unequal column length data frames
Ek Esawi
esawiek at gmail.com
Wed Feb 21 03:33:35 CET 2018
Hi All--
I have generated several 2 column data frames with variable length. The
data frames have the same column names and variable types. I was trying to
aggregate over the 2nd column for all the date frames, but could not figure
out how.
I thought i could make them all of equal length then combine them in 1 data
frame where i can use aggregate, the formula version
Or to put them in a list and loop use lapply but did not know how to do
that and thought there might be a simpler way.
Below is an example of 3 data frames and the desired result; note that some
levels don't appear in all and may be null over all variable, like the case
of dd on the desired result which i would like to list all levels even if
some are all null.
Thanks in advance,
EK
df1 df2 df3
c1 c2 c1 c2 c1 c2
1 aa 1 bb 1 aa
2 aa 2 bb 2 aa
3 bb 3 cc
4 cc 4 bb
5 bb
desired result
c1 c2 c2 c2
aa 2 2
bb 1 2 2
cc 1 1
dd
[[alternative HTML version deleted]]
More information about the R-help
mailing list