Guest User

Untitled

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