Skip to content
Prev 174874 / 398503 Next

Merging rows in dataframes

Thank you, your answer was extremely helpful. One last problem though: one
of the aggregate functions I'd like to apply on the columns is
concatentation (equivalent to the paste() function). So if I have a given
character column in three separate rows sharing the same ids with the value
"apple" in the first, "banana" in the second, and "orange" in the third, in
the summarizing row I'd like to receive output in the form
"apple|banana|orange". Is there any way to do this? 

Thanks again,
Schragi

-----Original Message-----
From: Gabor Grothendieck [mailto:ggrothendieck at gmail.com] 
Sent: Tuesday, March 24, 2009 12:50 AM
To: Schraga Schwartz
Cc: r-help at r-project.org
Subject: Re: [R] Merging rows in dataframes

Using sqldf you only need two statements, infile <- file(...) and
DF <- sqldf("select min(a), max(b), mean(c), ... from infile group by id").
The file statement identifies the filename and the second reads it
into sqlite (without
going through R), summarizes it and then reads the summarized version
into R.  You may also need to provide info on its format if its not in the
default format.  See example 4a on home page and the other examples
there:
http://sqldf.googlecode.com


On Mon, Mar 23, 2009 at 5:58 PM, Schraga Schwartz
<schragas at post.tau.ac.il> wrote:
column
the
will
minimum,
up
function,
http://www.R-project.org/posting-guide.html