set_to_na: Set values to NA

Description Usage Arguments Value Author(s) Examples

View source: R/set_to_na.R

Description

This function takes a data.frame and sets specified values to NA

Usage

1
set_to_na(data, values.to.set.to.na)

Arguments

data

a data.frame

values.to.set.to.na

a character vector specifying values to set to NA

Value

a dataframe with specified values set to NA

Author(s)

Daniel Gardiner (daniel.gardiner@phe.gov.uk)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# set dummy data

set.seed(4)

data = data.frame(dates = sample(seq(as.Date('2014-01-01'), as.Date('2016-04-01'), by="day"), 20, replace = TRUE),
                  sex = factor(c("Male", "Female", "Female", NA)),
                  conf = factor(sample(c("Confirmed", "Probable", "Possible"), 20, replace = TRUE)),
                  status = sample(c("Student", "Staff", NA), 20, replace = TRUE),
                  age = sample(c(1:20, NA), 20, replace = TRUE),
                  stringsAsFactors = FALSE)

# apply function

set_to_na(data, c("Male", "Student"))

DanielGardiner/EpiFunc documentation built on July 25, 2019, 10:53 p.m.