miss2na:

Usage Arguments Examples

Usage

1
miss2na(m, na.val = NULL)

Arguments

m
na.val

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (m, na.val = NULL) 
{
    if (is.null(na.val)) 
        stop("Specify a missing value")
    if (is.vector(m)) {
        if (!is.list(m)) {
            flag = (m == na.val)
            m[flag] = NA
        }
    }
    if (is.matrix(m)) {
        for (j in 1:ncol(m)) {
            x = m[, j]
            flag = (x == na.val)
            x[flag] = NA
            m[, j] = x
        }
    }
    if (is.list(m)) {
        for (j in 1:length(m)) {
            x = m[[j]]
            flag = (x == na.val)
            x[flag] = NA
            m[[j]] = x
        }
    }
    m
  }

musto101/wilcox_R documentation built on May 23, 2019, 10:52 a.m.