[R] Combine subsets by factor level

John Kane jrkrideau at inbox.com
Wed Jun 6 14:36:26 CEST 2012


We really should have some sample data (see dput() for a handy way to post some).

However have a look at ?reshape,  the plyr and reshape packages or perhaps the data.table package.


John Kane
Kingston ON Canada


> -----Original Message-----
> From: libgray3827 at gmail.com
> Sent: Tue, 5 Jun 2012 21:07:50 -0700 (PDT)
> To: r-help at r-project.org
> Subject: [R] Combine subsets by factor level
> 
> I'm attempting to change a data set by compressing rows into columns.
> Currently there are several rows that all have information about one
> "patient," but at different cycles. I'm trying to make each patient only
> have one row in the data set.
> 
> Does anyone know a good way to combine data sets by factor level? I've
> separated the groups into different subsets by cycle, but not every
> patient
> has data for every cycle (i.e. there are 1200 who have cycle 0, but only
> 200
> of those have a cycle 1, and a different number have cycles higher than
> that, etc). I then made the patient number the identifying label. If
> there
> is a way to column-combine these subsets by the factor level of these
> patient names, and leave any patients that are missing a cycle as NA?
> 
> If anyone has insight on how to do this, or a better way to complete what
> I'm trying to do, I'd appreciate it!
> 
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Combine-subsets-by-factor-level-tp4632472.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at 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.

____________________________________________________________
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!



More information about the R-help mailing list