[R] Merge rows
sarah.goslee at gmail.com
Fri Jul 11 21:44:53 CEST 2014
I don't think your x2 is right, but who knows?
One possible approach would be:
R> lapply(split(x2$recipients, unique(x2$sender)), paste, collapse=", ")
$`a at email.com`
 "b at email.com, f at email.com"
$`r at email.com`
 "c(\"c at email.com\", \"d at email.com\"), h at email.com"
but again, who knows exactly what the OP wants?
You sent this just to me; I've copied the R-help list back again.
On Fri, Jul 11, 2014 at 3:19 PM, John McKown
<john.archie.mckown at gmail.com> wrote:
> On Fri, Jul 11, 2014 at 11:27 AM, Sarah Goslee <sarah.goslee at gmail.com> wrote:
>> Hi Ryan,
>> We can't tell from your example what structure your original data are
>> in, nor what your output is intended to look like, or for that matter
>> how you got from one to the other. Please don't post in HTML because
>> it gets mangled!
>> Using dput() to provide your example data is the best thing, because
>> that preserves R structures. And an R-format example of your desired
>> output would also be helpful.
> In a, perhaps vain, attempt to be helpful, I think the following
> output from what I constructed myself will show what the OP was
> talking about:
> structure(list(sender = c("a at email.com", "a at email.com", "r at email.com",
> "r at email.com"), recipients = list("b at email.com", c("c at email.com",
> "d at email.com"), "f at email.com", "h at email.com")), .Names = c("sender",
> "recipients"), row.names = c(NA, -4L), class = "data.frame")
> I probably should have called it "mailingList" instead of x2, no?
> Now, after "wasting" too much time, perhaps somebody will come up with
> a solution. I could "brute force" something (yes, you can write
> FORTRAN style code in R!). But have been "sensitized" from doing so by
> There is nothing more pleasant than traveling and meeting new people!
> Genghis Khan
> Maranatha! <><
> John McKown
More information about the R-help