set_na_to: Set NAs to a value

Description Usage Arguments Author(s) Examples

View source: R/set_na_to.R

Description

Set NAs to a value

Usage

1
set_na_to(data, value.to.set.na.to)

Arguments

data

a data.frame

value.to.set.na.to

a character vector specifying the value to set NA to

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_na_to(data, c("Unknown"))

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