Learn R Programming

mde (version 0.3.3)

recode_as_na_for: Recode Values as NA if they meet defined criteria

Description

Recode Values as NA if they meet defined criteria

Usage

recode_as_na_for(df, criteria = "gt", value = 0, subset_cols = NULL)

Value

A data.frame object with the required changes.

Arguments

df

A data.frame object to manipulate

criteria

One of gt,gteq,lt,lteq to define greater than, greater than or equal to, less than or less than or equal to.

value

The value to convert to `NA`. We can for instance change "n/a" to `NA` or any other value.

subset_cols

An optional character vector for columns to manipulate.

Examples

Run this code
recode_as_na_for(airquality,value=36, criteria = "gteq",
subset_cols = c("Ozone","Solar.R"))

Run the code above in your browser using DataLab