diff --git a/R/ukhls_combine_hhold_smokers.R b/R/ukhls_combine_hhold_smokers.R index 38cb189..e48983d 100644 --- a/R/ukhls_combine_hhold_smokers.R +++ b/R/ukhls_combine_hhold_smokers.R @@ -22,7 +22,7 @@ ukhls_combine_hhold_smokers <- function(data = NULL) { hhold <- hhold[, `NA` := NULL] hhold <- hhold[, non_smoker := NULL] hhold <- hhold[, smoker := NULL] - data <- merge(data, hhold, by = "hidp") + data <- suppressWarnings(suppressMessages(merge(data, hhold, by = "hidp"))) return(data) } diff --git a/R/ukhlsclean.R b/R/ukhlsclean.R index 3d7d183..ff37ebe 100644 --- a/R/ukhlsclean.R +++ b/R/ukhlsclean.R @@ -194,6 +194,10 @@ data <- ukhlsclean::ukhls_combine_waves(data_list) ### Summation of smokers in household data <- ukhls_combine_hhold_smokers(data) +##################################### +### Lag household smokers to (t-1) +data <- data[order(pidp, wave_no), lag.s_hhold_smokers := data.table::shift(s_hhold_smokers, n=1, type="lag"), by=pidp] + ################################### ### Combine youth data