package_trial1: MCAR: Missing completely at random

Description Usage Arguments Examples

Description

mcar() alows the user to forcibly input missing values (NA) that replicates being missing completly at random. This kind of missing data is missing by random chance.

Usage

1
mcar(data, p, column = NULL)

Arguments

data

The data that you want to give missing values to

p

The percentage of data that you want to make missing.

column = NULL

When NULL the function will run through your whole data set Set a value to target specific columns

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Inputs missing data in the first two columns of the data set df

df<- data.frame(x=rnorm(100, 10, 2), y=rpois(100,4), z=rbinom(100, 1, .4))
df_missing<- mcar(df, .25, 1:2)
sum(is.na(df_missing))/200

## Inputs missing data into all of the columns in df2

df2<- data.frame(x=rnorm(100, 10, 2), y=rpois(100,4), z=rbinom(100, 1, .4))
df_missing2<- mcar(df2, .25)
sum(is.na(df_missing2))/300

JerryTucay/mfdata documentation built on May 7, 2019, 6:56 p.m.