#' attach Modification Code Description File
#' Modification Code Description File
#' @param data data
#' @param lower_cd logical
#'
#' @return
#' @export
#'
attach_MCD <- function(data,lower_cd=FALSE){
years <- unique(data$Year)
mcd <- nhs_tsv('drxmcd',years = years,cat = FALSE)
n0 <- nhs_read(mcd,cat = FALSE,lower_cd=lower_cd)
n0 <- drop_col(n0,'Year')
if (all(c('dr1mc','dr2mc') %in% colnames(data))){
data <- dplyr::left_join(data,n0,c('dr1mc'='drxmc'))
data <- dplyr::left_join(data,n0,c('dr2mc'='drxmc'),suffix = c('_1','_2'))
}else if ('dr1mc' %in% colnames(data)){
data <- dplyr::left_join(data,n0,c('dr1mc'='drxmc'))
}else if ('dr2mc' %in% colnames(data)){
data <- dplyr::left_join(data,n0,c('dr2mc'='drxmc'))
}else{
if (do::cnOS()) stop(tmcn::toUTF8("\u5FC5\u987B\u662Fiff\u6570\u636E"))
if (!do::cnOS()) stop('must be iff data')
}
return(data)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.