Learn R Programming

memisc (version 0.99.31.7)

neg2mis: Mark Negative Values as Missing

Description

In many newer survey data sets available from social science data archives non-valid responses (such as "don't know" or "answer refused") are given negative codes. The function neg2miss allows to mark them as missing values.)

Usage

neg2mis(x,all=FALSE,exclude=NULL,select=NULL,zero=FALSE)

Arguments

x

an object that inherits from class "item.list", e.g. a "data.set" or an "importer" object.

all

logical; should the marking of negative values as missing applied to all variables?

exclude

an optional vector of variable naems to which the marking of negative values as missing should not be applied.

select

an optional vector of variable names to which the marking of negative values as missing should be applied.

zero

logical; should zeroes also be marked as missing?

Examples

Run this code
ds <- data.set(
          var1 = c(0,1,-1,2,3),
          var2 = c(-1,-1,1,1,1),
          var3 = c(1,2,3,4,5)
          )
neg2mis(ds,all=TRUE)
neg2mis(ds,all=TRUE,zero=TRUE)
neg2mis(ds,exclude=var1)
neg2mis(ds,select=var1)

Run the code above in your browser using DataLab