Learn R Programming

holodeck (version 0.2.2)

sim_missing: Simulate missing values

Description

Takes a data frame and randomly replaces a user-supplied proportion of values with `NA`.

Usage

sim_missing(.data, prop, seed = NA)

Value

a dataframe with NAs

Arguments

.data

A dataframe.

prop

Proportion of values to be set to `NA`.

seed

An optional seed for random number generation. If `NA` (default) a random seed will be used.

Examples

Run this code
library(dplyr)
df <- sim_cat(n_obs = 10, n_groups = 2) %>%
sim_covar(n_vars = 10, var = 1, cov = 0.5) %>%
sim_missing(0.05)

Run the code above in your browser using DataLab