Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(data.table)
- data <- data.table(id = c(5, 5, 4, 4, 3, 3, 2, 2, 1, 1),
- time = c(2, 8, 5, 10, 3, 10, 4, 9, 1, 7),
- censored = sample(c("Y", "N"), 10, TRUE))
- library(lattice)
- xyplot(id ~ time, data, groups = id, type = "l",
- panel = function(x, y, groups = groups, ...){
- panel.xyplot(x, y, groups = groups, ...)
- fillColors <- sapply(data$censored == "Y", function(x){
- ifelse(x, "white", "red")
- })
- panel.points(x, y, pch = 21, cex = 1.5, fill = fillColors)
- }, key = list(space = "top", text = list(c("complete", "censored")),
- points = list(fill = c("white", "red"),
- cex = c(1.5, 1.5), pch = c(21, 21))))
Advertisement
Add Comment
Please, Sign In to add comment