Oops! Ok So I have this file: SampleName Individual Age Gender 1 4 80 M 2 15 56 F 3 1 75 F 4 15 56 F 5 2 58 F 6 4 80 M
And I want to pull out paired samples, so the resulting file would look something like this: SampleName Individual Age Gender 1 4 80 M 2 15 56 F 4 15 56 F 6 4 80 M .kripa > Date: Mon, 12 Aug 2013 18:36:08 -0700 > From: smartpink...@yahoo.com > Subject: Re: [R] pulling out pairs from data frame > To: kripa...@hotmail.com > CC: r-help@r-project.org > > Hi, > The question is not clear so not sure this is what you wanted. > > dat1<- read.table(text=" > SameName áIndividual áAge Gender > 1 4 á80 áM á > 2 15 á56 F > 3 1 75 áF > 4 15 á56 áF > 5 á2 á58 áF > 6 4 á80 áM > ",sep="",header=TRUE,stringsAsFactors=FALSE) > reps<-c(4,15)á > > ádat1$Newcol<-as.numeric(dat1$Individual%in% reps) > ádat1 > # áSameName Individual Age Gender Newcol > #1 á á á á1 á á á á á4 á80 á á áM á á á1 > #2 á á á á2 á á á á 15 á56 á á áF á á á1 > #3 á á á á3 á á á á á1 á75 á á áF á á á0 > #4 á á á á4 á á á á 15 á56 á á áF á á á1 > #5 á á á á5 á á á á á2 á58 á á áF á á á0 > #6 á á á á6 á á á á á4 á80 á á áM á á á1 > A.K.á > > > > > ----- Original Message ----- > From: Kripa R <kripa...@hotmail.com> > To: "r-help@r-project.org" <r-help@r-project.org> > Cc: > Sent: Monday, August 12, 2013 6:59 PM > Subject: [R] pulling out pairs from data frame > > Hello everyone, > I'm having trouble pulling out paired samples from a data set... I have the > following: > > reps<-c(4,15) #the variable reps is a list of all paired samples > >data > > > > > > á > á SameName > á > á > á Individual > á > á > á Age > á > á > á Gender > á > > > á > á 1 > á > á > á 4 > á > á > á 80 > á > á > á M > á > > > á > á 2 > á > á > á 15 > á > á > á 56 > á > á > á F > á > > > á > á 3 > á > á > á 1 > á > á > á 75 > á > á > á F > á > > > á > á 4 > á > á > á 15 > á > á > á 56 > á > á > á F > á > > > á > á 5 > á > á > á 2 > á > á > á 58 > á > á > á F > á > > > á > á 6 > á > á > á 4 > á > á > á 80 > á > á > á M > á > > > > > I'd like to make a new variable with only the samples that have pairs. Any > suggestions would be greatly appreciated > > Thanks! > > > > > > .kripa > ááá ááá ááá á ááá ááá á > ááá [[alternative HTML version deleted]] > > ______________________________________________ > 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. > [[alternative HTML version deleted]]
______________________________________________ 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.