miss_add_random: Insert random NAs into a data.frame.

View source: R/missing_data.R

miss_add_randomR Documentation

Insert random NAs into a data.frame.

Description

Inserts missing data into a data.frame at random, thus creating data that are Missing Completely At Random (MCAR). THis isn't how data usually are missing in the real world, but may be sufficient for some situations.

Usage

miss_add_random(df, prop = 0.1)

Arguments

df

(data.frame) A data.frame.

prop

(num vector) The proportion of NAs to add.

Value

A data.frame.

Examples

df = data.frame(c(1:10), letters[1:10]) #example data
miss_add_random(df) #add 10% random NAs
miss_amount(df) #verify that 10% really is missing

Deleetdk/kirkegaard documentation built on May 2, 2024, 7:12 p.m.