Learn R Programming

sknifedatar (version 0.1.2)

insert_na: Add NA values to a dataframe

Description

allows adding NA values to a data frame, selecting the columns and the proportion of desired NAs.

Usage

insert_na(.dataset, columns, .p = 0.01, seed = 123)

Arguments

.dataset

data frame.

columns

vector that indicates the name of the columns where the NA values will be added, in the format: c("X1", "X2") for variables X1, X2.

.p

value between 0 and 1, indicating the proportion of NA values that will be added.

seed

random number seed.

Value

the original data frame, but with the NA values added in the indicated columns.

Examples

Run this code
# NOT RUN {
insert_na(.dataset = iris, columns = c("Sepal.Length","Petal.Length"), .p = 0.25)
# }

Run the code above in your browser using DataLab