check types
# 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.types.R - Verify types of variable.
####################################################################################
# Check and return a numeric value
check.types(data.to.work, message = 1)
# Adding random data to data.to.work, function will return TRUE
data.to.work$Z <- round(runif(500, min=0, max=1000),2)
# Converting the numeric variable into factor
data.to.work$Z <- factor(data.to.work$Z)
# Check and return a numeric value correspondig to: 1=integer, 2=numeric, 3=factor, 4=integer and
# numeric, 5=integer and factor, 6=numeric and factor or 7=integer, numeric and factor.
check.types(data.to.work, message = 1)
# Supressing the message
check.types(data.to.work, message = 0)
###################################################################################
RESULTS:
###################################################################################
Observe, when we have only numeric data the return is 2 with numeric and factor return is 6:
Obs: 1=integer, 2=numeric, 3=factor, 4=integer and numeric, 5=integer and factor, 6=numeric and factor, 7=integer, numeric and factor