[R] number of pairwise present data in matrix with missings

Frank E Harrell Jr f.harrell at vanderbilt.edu
Tue Nov 23 15:25:52 CET 2004


Andreas Wolf wrote:
> is there a smart way of determining the number of pairwise present data
> in a data matrix with missings (maybe as a by-product of some
> statistical function?)
> 
> so far, i used several loops like:
> 
> for (column1 in 1:99) {
>   for (column2 in 2:100) {
>     for (row in 1:500) {
>       if (!is.na(matrix[row,column1]) & !is.na(matrix[row,column2])) {
>         pairs[col1,col2] <- pairs[col1,col2]+1
>       }
>     }
>   }
> }
> 
> but this seems neither the most elegant nor an utterly fast solution.
> 
> thanks for suggestions.
> andreas wolf

library(Hmisc)
n <- naclus(mydataframe)
plot(n)   # show pairwise missingness in a dendogram
naplot(n) # show more details in multiple plots

Frank

-- 
Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University




More information about the R-help mailing list