misscode.default: Turns NAs into a value below the range of non-missing data...

Description Usage Arguments Examples

View source: R/fun.R

Description

misscode turns NAs of numerical variables into a value slightly less that non-missing values. Missing values for factors are made into a non-missing level. When applied to a data frame, a new variable .nmiss is added to the data frame indicating the number of variables with missing data in each row of the data frame.

Usage

1

Arguments

x
...
offset

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
##---- 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 (x, ..., offset = 0.1) 
{
    rr <- range(x, na.rm = TRUE)
    vmiss <- min(x, na.rm = TRUE) - offset * diff(rr)
    nas <- is.na(x)
    x[nas] <- vmiss
    attr(x, "nas") <- nas
    x
  }

gmonette/spida documentation built on May 17, 2019, 7:25 a.m.