check.dichotomic.one.var: Verify if one specific variable of a data set is dichotomic

Description Usage Arguments Value Author(s) References Examples

View source: R/check.dichotomic.one.var.R

Description

This function receives a data set and the name of a specific variable and verify if it is dichotomic or not. If 'yes' then the function return TRUE.

Usage

1
check.dichotomic.one.var(data.to.work, variable.name)

Arguments

data.to.work

is a data set containing the variables to be checked.

variable.name

is the name of a variable to be checked.

Value

TRUE or FALSE

Author(s)

Elias Carvalho

References

HAYES, A F; PREACHER, K J. Statistical mediation analysis with a multicategorical independent variable. British Journal of Mathematical and Statistical Psychology, v. 67, n. 3, p. 451-470, 2014.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 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)
# Show the structure of data set
str(dataQuantC)
# Set variable name
variable.name = "A"
# data set has not dichotomic variables and function will return FALSE
check.dichotomic.one.var(dataQuantC, variable.name)
# Adding dichotomic data to dataQuantC
dataQuantC$Z <- round(runif(500, min=0, max=1),0)
# Show the new structure of data set
str(dataQuantC)
# Set variable name
variable.name = "Z"
# Now data set has dichotomic variables and function will return TRUE
check.dichotomic.one.var(dataQuantC, variable.name)

bnpa documentation built on Aug. 2, 2019, 1:05 a.m.