Description Usage Arguments Details Examples
nmar() alows the user to forceibly input missing values (NA) that replicates being not missing at random. This kind of missing depends strictly on the variable's value. If Xi > p% of max value for Xi then there is q% chance the data point is missing.
1 |
data |
The data frame that you want to put missing values into. |
p |
Percent of the the max value in the specified column |
q |
Percent chance the Xi data point is missing given Xi> p% of max |
column = NULL |
When NULL the function will run through your whole data set Set a value to target specific columns |
Definintly play around with p and q if you want to get a specfic amount of data missing.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ## Inputs missing data in all the columns in df
df<- data.frame(x=rnorm(100, 10, 2), y=rpois(100,4), z=rbinom(100, 1, .4))
df_missing<- nmar(df, .25)
sum(is.na(df_missing))/300
## Inputs missing data for columns one and three of df2
df2<- data.frame(x=rnorm(100, 10, 2), y=rpois(100,4), z=rbinom(100, 1, .4))
df_missing2<- nmar(df2, p=.5, q=.2 , c(1,3))
sum(is.na(df_missing2))/200
{ ~kwd1 }
{ ~kwd2 }
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.