Learn R Programming

sjPlot (version 1.7)

set_na: Set NA for specific variable values

Description

This function sets specific values of a variable var as missings (NA).

Usage

set_na(var, values)

Arguments

Value

The var where each value of values replaced by an NA.

Examples

Run this code
# create random variable
dummy <- sample(1:8, 100, replace=TRUE)
# show value distribution
table(dummy)
# set value 1 and 8 as missings
dummy <- set_na(dummy, c(1,8))
# show value distribution, including missings
table(dummy, exclude=NULL)

Run the code above in your browser using DataLab