[R] Aggregate over multiple and unequal column length data frames
bgunter.4567 at gmail.com
Wed Feb 21 04:31:54 CET 2018
All columns in a data.frame **must** have the same length. So you cannot do
this unless empty values are filled with missings (NA's).
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Tue, Feb 20, 2018 at 6:33 PM, Ek Esawi <esawiek at gmail.com> wrote:
> 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,
> 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
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/
> and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
More information about the R-help