data("pbc2", package = "JM")
pbc2$id <- factor(pbc2$id, levels = levels(pbc2$id),
labels = paste0("A", levels(pbc2$id)))
pbc2$status2 <- as.numeric(pbc2$status != "alive")
pbc2$status3 <- as.character(pbc2$status)
ff <- function (x) {
out <- if (x[1L] %in% c('dead', 'transplanted')) 'dead' else
switch(sample(1:3, 1), '1' = "alive", '2' = "left", '3' = "interval")
rep(out, length(x))
}
pbc2$status3 <- unlist(with(pbc2, lapply(split(status3, id), ff)), use.names = FALSE)
pbc2$status3 <- unname(with(pbc2, sapply(status3, function (x)
switch(x, 'dead' = 1, 'alive' = 0, 'left' = 2, 'interval' = 3))))
pbc2$yearsU <- as.numeric(NA)
pbc2$yearsU[pbc2$status3 == 3] <- pbc2$years[pbc2$status3 == 3] +
runif(sum(pbc2$status3 == 3), 0, 1)
pbc2.id <- pbc2[!duplicated(pbc2$id), ]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.