Guest User

Untitled

a guest
Jan 22nd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. set.seed(1)
  2. M1 <- sample(c("N","Y"), 10, replace = T)
  3. M2 <- sample(c("N","Y"), 10, replace = T)
  4. M3 <- sample(c("N","Y"), 10, replace = T)
  5. M1[5] <- NA; M2[7] <- NA; M3[3] <- NA
  6. meds <- data.frame(M1,M2,M3)
  7. meds$counts.NA <- apply(meds, 1, function(x) { y <- x=="Y"; sum(y)})
  8. meds$counts.noNA <- apply(meds, 1, function(x) { y <- x=="Y"; sum(y, na.rm = T)})
Add Comment
Please, Sign In to add comment