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 <kripa777 at hotmail.com>
To: "r-help at r-project.org" <r-help at 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 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.