Please consider the following inputs:
PrsnSerialno<-c(735,1147,2019,4131,4131,4217,4629,4822,4822,5979,5979,6128,6128,7004,7004,
7004,7004,7004,7438,7438,9402,9402,9402,10115,10115,11605,12693,12693,12693)

PrsnAge<-c(59,48,42,24,24,89,60,43,47,57,56,76,76,66,70,14,7,3,62,62,30,10,7,20,21,50,53,44,29)

IsHead<-c(TRUE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,FALSE,TRUE,TRUE,FALSE,TRUE,FALSE,FALSE,TRUE,FALSE,FALSE,
FALSE,TRUE,FALSE,TRUE,FALSE,FALSE,FALSE,TRUE,FALSE,TRUE,FALSE,FALSE)

PrsnData<-cbind(PrsnSerialno,PrsnAge,IsHead)

HhSerialno<-c(735,1147,2019,4131,4217,4629,4822,5979,6128,7004,7438,9402,10115,11605,12693)
HhData<-cbind(HhSerialno)

What i would like to do is to add a age column to HhData that would
correspond to the serial number and which is also the oldest person in the
house, or what corresponds to "TRUE"(designates oldest person).  The TRUE
false doesnt have to be considered but is preferable.  

The result would then be:
HhSerialno HhAge
735     59
1147    48
2019    42
4131    24
4217    89
4629    60
4822    47
5979    57
6128    76
7004    70
7438    62
9402    30
10115   21
11605   50
12693   53

I tried
PumsHh..$Age<-PumsPrsn[PumsPrsn$SERIALNO==PumsHh..$Serialno,PumsPrsn$AGE]
but becaseu teh data frames are of different length it doesnt work so im
unsure of another way of doing this.  Thanks in advance

JR

-- 
View this message in context: 
http://www.nabble.com/Referencing-columns-and-pulling-selected-data-tp24813802p24813802.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.

Reply via email to