#' attach_Menopause
#'
#' @param data data
#' @param years years
#' @param Year logical
#' @details judge by rhq031(yes), rhd042(menopause)
#' @return yes or no
#' @export
#'
attach_Menopause <- function(data,years,Year=FALSE){
if (!missing(data)) years <- unique(data$Year)
years <- prepare_years(years)
rhq <- nhs_tsv('rhq',years = years,cat = FALSE)
d <- nhs_read(rhq,'rhd042','rhq031',lower_cd = TRUE,cat = FALSE)
d <- to_NA(d)
d$rhd042[!grepl('menop',d$rhd042) & !is.na(d$rhd042)] <- 0
d$rhd042[grepl('menop',d$rhd042) & !is.na(d$rhd042)] <- 1
d$rhd042 <- as.numeric(d$rhd042)
d$rhq031 <- recode(d$rhq031,
"yes::1",
"no::0") |> as.numeric()
ck <- rowsum(d[,c("rhd042","rhq031")]) >=1
d$menstrual[ck] <- 'yes'
d$menstrual[!ck] <- 'no'
d <- d[,c("Year","seqn","menstrual")]
if (!Year) d <- drop_col(d,'Year')
if (missing(data)) return(d)
dplyr::left_join(data,d,'seqn')
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.