Learn R Programming

bnpa (version 0.3.0)

check.type.one.var: Verify the type of one variable

Description

Receives a specific variable and return a number indicating its type. The variables can be 1 is integer, 2 is numeric, 3 is factor, 8 is character.

Usage

check.type.one.var(data.to.work, show.message = 0, variable.name)

Arguments

data.to.work

is a data set containing the variables to be verified.

show.message

is a parameter indicating if the function will or not show a message.

variable.name

is the name of variable to be checked.

Value

A variable with the code indicating the type of variable and a message (or not).

References

GUJARATI, Damodar N. Basic econometrics. Tata McGraw-Hill Education, 2009.

Examples

Run this code
# NOT RUN {
# Clean environment
closeAllConnections()
rm(list=ls())
# Set enviroment
# setwd("to your working directory")
# Load packages
library(bnpa)
# Use working data sets from package
data(dataQuantC)
head(dataQuantC)
# Adding random data to dataQuantC, function will return TRUE
dataQuantC$Z <- round(runif(500, min=0, max=1000),2)
# Converting the numeric variable into factor
dataQuantC$Z <- factor(dataQuantC$Z)
# Check and return a numeric value correspondig to the variable type
# Set the variable name
variable.name = "A"
# identify the type
check.type.one.var(dataQuantC, show.message=0, variable.name)
# Set the variable name
variable.name = "Z"
# identify the type
check.type.one.var(dataQuantC, show.message=0, variable.name)
# }

Run the code above in your browser using DataLab