[R] Finding Missing Data Patterns
ligges at statistik.uni-dortmund.de
Sun Feb 2 12:36:02 CET 2003
Wolfgang Viechtbauer wrote:
> Dear R-Helpers,
> I have a large data matrix, which contains missing data. The matrix
> looks something like this:
> 1) X X X X X X NA NA NA
> 2) NA NA NA NA X X X X X
> 3) NA NA X X X X NA NA NA
> 4) X X X X X X X X X
> 5) X X NA NA X NA NA NA NA
> and so on. Notice that the first row starts with complete data but ends
> with missing. The second row starts with missing, but the rest is
> complete. The third starts and ends with missing, but the middle part is
> complete. The fourth is complete. What I want to do is filter out
> patterns like in row 5, where the data are interrupted by missing data.
> Basically, I need to test each row for a "data, at least one NA, data"
> Is there some kind of way of doing this? I am at a loss for an easy way
> to accomplishing this. Any suggestions would be most appreciated!
> Wolfgang Viechtbauer
Presumably not most efficient, but it came into my mind at first:
apply(X, 1, function(x) grep("0.1.0", paste(as.numeric(is.na(x)),
More information about the R-help