View source: R/adult-mortality.R
reshape_sib_data | R Documentation |
Convert respondent-level sibling history data to one row per sibling
reshape_sib_data( data, widevars = grep("^v", names(data), value = TRUE), longvars = grep(sibvar_regex, names(data), value = TRUE), idvar = "caseid", sib_vars = sub("(.*)_.*", "\\1", longvars), sib_idvar = "mmidx", sibvar_regex = "^mm[idx0-9]" )
data |
A dataset as |
widevars |
Character vector of respondent-level variable names to include. |
longvars |
Character vector of variables corresponding to each sibling. |
idvar |
Vector of variable names uniquely identifying each respondent. |
sib_vars |
Vector of same length as longvars giving variable names in long dataset. |
sib_idvar |
Variable name uniquely identifying each sibling record. Should appear amongst |
sibvar_regex |
Optionally, a regular expression to identify variable names for |
data(zzir) zzsib <- reshape_sib_data(zzir) zzsib$death <- factor(zzsib$mm2, c("dead", "alive")) == "dead" zzsib$sex <- factor(zzsib$mm1, c("female", "male")) # drop mm2 = 3: "missing" calc_nqx(zzsib, by=~sex, agegr=seq(15, 50, 5), tips=c(0, 7), dob="mm4", dod="mm8")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.