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.
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!
Shilpi Harpavat (PDF)
2012-Jun-06 14:51 UTC
[R] Source code for simple Forward step wise regression .
Hi , I want to implement a simple forward stepwise regression in java which fits a linear model with no term and then add terms one by one .What would be the best algorithm to use along with Criterion for what terms to keep /Drop and when to Stop. Any help appreciated. Thanks -- *The information in this email and any attachments to it may be confidential and/or privileged. Unless you are the intended recipient (or authorized to receive it on behalf of the intended recipient), you may not use, copy, or disclose to anyone the message or attachments, in whole or in part. If you believe that you have received the message in error, please delete it forever from your systems and trash, and advise the sender by reply email. ? 2012 PDF Solutions Inc. All rights reserved.*
Hi Iglucia, I am not sure how your dataset looks like.? Does it look similar to this:> dat4<-data.frame(patient=rep(c(1:10), rep(3,10)),var=rep(c("cycle0","cycle1","cycle2"),rep(1,3)),value=c(rnorm(15,1,0.5),NA,rnorm(5,1,0.5),NA,rnorm(8,1,0.5))) > dat4?? patient??? var???? value 1??????? 1 cycle0 1.8826827 2??????? 1 cycle1 1.0316985 3??????? 1 cycle2 1.0084754 4??????? 2 cycle0 1.1822553 5??????? 2 cycle1 1.5494087 6??????? 2 cycle2 0.9173749 7??????? 3 cycle0 0.3935503 8??????? 3 cycle1 0.7012282 9??????? 3 cycle2 0.5213031 10?????? 4 cycle0 0.8330390 11?????? 4 cycle1 0.6430550 12?????? 4 cycle2 0.7751283 13?????? 5 cycle0 1.4092714 14?????? 5 cycle1 0.8120330 15?????? 5 cycle2 0.6255491 16?????? 6 cycle0??????? NA 17?????? 6 cycle1 0.1068520 18?????? 6 cycle2 0.7556006 19?????? 7 cycle0 1.4322698 20?????? 7 cycle1 1.6109262 21?????? 7 cycle2 0.9650534 22?????? 8 cycle0??????? NA 23?????? 8 cycle1 0.3861208 24?????? 8 cycle2 1.1349206 25?????? 9 cycle0 1.5659958 26?????? 9 cycle1 1.8725942 27?????? 9 cycle2 1.5676570 28????? 10 cycle0 1.0895054 29????? 10 cycle1 1.1941775 30????? 10 cycle2 1.3932515 ? A.K. ----- Original Message ----- From: lglucia <libgray3827 at gmail.com> To: r-help at r-project.org Cc: Sent: Wednesday, June 6, 2012 12:07 AM 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.