r_na {wakefield} | R Documentation |
Replace a Proportion of Values With NA
Description
Replaces a proportion of values with NA. Useful for simulating missing data.
Usage
r_na(x, cols = -1, prob = 0.05)
Arguments
x |
A |
cols |
Numeric indices of the columns to incude (use |
prob |
The proportion of each column/vector elements to assign to
|
Value
Returns a data.frame
or list
with random missing values.
Examples
r_na(mtcars)
r_na(mtcars, NULL)
library(dplyr)
r_data_frame(
n = 30,
id,
race,
age,
sex,
hour,
iq,
height,
died,
Scoring = rnorm,
Smoker = valid
) %>%
r_na(prob=.4)
[Package wakefield version 0.3.6 Index]