Title

Description

Description

Usage

1
r_na(x, cols = -1, prob = 0.05)

Arguments

x

A data.frame or list to randomly replace elements with NAs.

cols

Numeric indices of the columns to incude (use - to exlcude as well). Default is to assign random NAs to al columns except the first column.

prob

The proportion of each column/vector elements to assign to NA.

Value

Returns a data.frame or list with random missing values.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
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)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.