Learn R Programming

psyosphere (version 0.1.6)

val_var: Validate variables

Description

Validates variables before further procedure execution.

Usage

val_var(test_var, type, force = 2, size = 0, def = FALSE)

Arguments

test_var

Multiple. The variable that is to be tested.

type

Character. The variable type determined by mode or lubridate::is.POSIXct. For example numeric, character, logical, list, POSIXct or ggplot.

force

numeric. Error message is sent as warning (1) or stop (2).

size

numeric. If size is not 0 the length of test_var will be checked with size.

def

logical. Ignore this check if cname = "".

See Also

val_cname,val_psyo, val_var

Examples

Run this code
# NOT RUN {
# Create variables
id <- 10
name <- "test"
time <- as.POSIXct("1986-08-31 02:15:00")

# Check variables
# e <- val_var(id, "character"); if (e != "") {stop(e)} # error and stop
# e <- val_var(name, "logical", FALSE); if (e != "") {stop(e)} # error and warning
e <- val_var(time, "POSIXct"); if (e != "") {stop(e)} # no error

# }

Run the code above in your browser using DataLab