File: na.pattern.s

package info (click to toggle)
hmisc 5.2-4-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,044 kB
  • sloc: asm: 28,905; f90: 590; ansic: 415; xml: 160; fortran: 75; makefile: 2
file content (13 lines) | stat: -rw-r--r-- 244 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
na.pattern <- function(x)
{
  k <- ncol(x)
  pattern <- ''
  idt <- is.data.table(x)
  for(i in 1 : k) {
    y <- if(idt) x[, ..i] else x[, i]
    pattern <- paste0(pattern, 1 * is.na(y))
    }
  table(pattern)
}
utils::globalVariables('..i')