#' Hospitalisations
#'
#' Transforme le dataset des hospitalisations pour l'inclure dans celui des Rx.
#'
#' @param data_Rx,data_hospit datasets.
#'
#' @return data.table. 5 colonnes : `ID`, `Rx`, `DateServ`, `Duree` et `Hospit=1`.
#' @keywords internal
#' @import data.table
#' @export
add_hospit2Rx <- function(data_Rx, data_hospit){
hospit2add <- unique(data_Rx[, .(ID, Rx)]) # liste des ID et leurs médicaments
hospit2add <- merge( # associer chaque hospitalisation à chaque Rx
hospit2add, data_hospit,
by = "ID",
allow.cartesian = T
)
hospit2add <- hospit2add[, .( # structure du dataset comme celui de Rx pour futur rbind()
ID,
Rx,
DateServ = Adm,
Duree = as.integer(Dep - Adm + 1),
Hospit = 1
)]
return(hospit2add)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.