
SubjectTag
. This value uniquely identifies subjects, when both generations are included in the same dataset.SubjectTag
uniquely identify subjects. For Gen2 subjects, the SubjectTag is identical to their CID (ie, C00001.00 -the SubjectID assigned in the NLSY79-Children files). However for Gen1 subjects, the SubjectTag is their CaseID (ie, R00001.00), with "00" appended. This manipulation is necessary to identify subjects uniquely in inter-generational datasets. A Gen1 subject with an ID of 43 becomes 4300. The SubjectTags of her four children remain 4301, 4302, 4303, and 4304.
CreateSubjectTag(subjectID, generation)
subjectID
and generation
are different lengths. If either input vector has NA values, the respective output element(s) will be NA too.
SubjectTag
in context, see the Links79Pair
dataset documentation.
Links79Pair
library(NlsyLinks) #Load the package into the current R session.
#Typically these two vectors will come from a data frame.
subjectIDs <- c(71:82, 10001:10012)
generation <- c(rep(1, 12), rep(2, 12))
CreateSubjectTag(subjectIDs, generation)
#Returns 7100, ..., 8200, 10001, ..., 10012
#Use the ExtraOutcomes79 dataset, with numeric variables 'SubjectID' and 'Generation'.
ExtraOutcomes79$SubjectTag <- CreateSubjectTag(
subjectID=ExtraOutcomes79$SubjectID,
generation=ExtraOutcomes79$Generation
)
Run the code above in your browser using DataLab