try this: > x <- read.table(textConnection(" user_id site_id name + 1 1 11 februari + 2 1 11 redbook + 3 1 11 tips + 7 3 6 sleep + 8 3 6 monitoring + 9 3 6 alarm"), header=TRUE) > closeAllConnections() > y <- lapply(split(x, list(x$user_id, x$site_id), drop=TRUE), function(.data){ + data.frame(user_id=.data$user_id[1], site_id=.data$site_id[1], + name=paste(as.character(.data$name), collapse=',')) + }) > do.call(rbind, y) user_id site_id name 3.6 3 6 sleep,monitoring,alarm 1.11 1 11 februari,redbook,tips
On Thu, Oct 16, 2008 at 4:43 AM, Dirkheld <[EMAIL PROTECTED]> wrote: > > Hi, > > I have the following data imported from a csv file > user_id site_id name > 1 1 11 februari > 2 1 11 redbook > 3 1 11 tips > 7 3 6 sleep > 8 3 6 monitoring > 9 3 6 alarm > > Which I would like to merge/combine into > user_id site_id name > 1 1 11 februari, redbook, tips > 2 3 6 sleep, monitoring, alarm > 3 ..... > > So I would like to combine data from similar user_id and site_id in one line > with a merge of the 'name'. > > > > -- > View this message in context: > http://www.nabble.com/merge-combine-data-tp20009538p20009538.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.