Kubasiewicz, Laura <laura.kubasiewicz08 <at> imperial.ac.uk> writes:
> I have a dataframe with columns for... > > 'I.D' 'age' 'mothers I.D' > 01 5 03 > 02 6 06 > 03 16 NA > 04 8 06 > 05 3 NA > 06 17 NA > > I need to create a new column for 'mothers age' which puts the age of the individual with 'mothers i.d' into > the row for her offspring (so individual 01 would have 16 in the mothers age column, as thats the age of > individual 03) > That's at typical join in SQL language, and it is handled in R with function merge. In your special case, you would merge the dataframe with itself, so something like merge(fr,fr, by... and check the NA cases) Dieter ______________________________________________ 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.