Skip to content

Not missing at random

2 messages · Blaz Simcic, Dennis Murphy

#
Hi:

Try this:

x <- matrix(c(rep(1:5, 9), rep(3, 3), 4), ncol = 7, byrow = TRUE)
## indices of x for which the value is less than 3
candidates <- which(x < 3, arr.ind = TRUE)    # generates 18 candidates
grabs <- sample(nrow(candidates), 15)          # 15/49 ~ 0.3
x2 <- x    # copy x
x2[candidates[grabs, ]] <- NA
x2

HTH,
Dennis
On Fri, Jun 3, 2011 at 5:49 AM, Blaz Simcic <blazsimcic at yahoo.com> wrote: