check NAs
# Clean environment
closeAllConnections()
rm(list=ls())
# Set enviroment
setwd("~/your working directory")
# Load packages
library(bnpa)
# Use working datasets from package
data.to.work <- dataQuantC
head(data.to.work)
###################################################################################
# check.na.R - Verify variables with NA..
###################################################################################
# Adding NAs to data.to.work # credits for the random NA code for: https://goo.gl/Xj6caY
data.to.work <- as.data.frame(lapply(data.to.work, function(cc) cc[ sample(c(TRUE, NA), prob = c(0.85, 0.15), size = length(cc), replace = TRUE) ]))
# Checking the NAs
check.na(data.to.work)
###################################################################################
RESULTS:
###################################################################################
The data set with NAs inserted:
After executing the check.na function: