go: go

Description Usage Arguments Value Examples

View source: R/General.R

Description

Tests if a value or object does not exist, is length 0, NULL, or NA and returns FALSE if it is, otherwise returns TRUE. Useful for conditional evaluation of a valid value for an object for further calculations or functions.

Usage

1
go(x, env = parent.frame())

Arguments

x

(string) An object or the name of an object to test for it's non-NuLL, non-NA, non-length(0) existence

env

(environment) An enviroment to search for the object, defaults to parent frame

Value

(boolean) A TRUE indicates the object exists, is not NULL, NA or length 0. Otherwise false.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
x <- {4/0}
go("x")
# Infinite is an acceptable value
x <- NaN
go("x")
x <- NA
go("x")
x <- NULL
go("x")
x <- numeric(0)
go("x")
x <- list()
x$go <- 2
go("x$go")
go("x[['go']]")
go(x[['go']])
df <- data.frame(a = c(1,2), b = c(3,4))
go("df[2,'a']")
df[2,'a'] <- NA
x$df <- df
go("x[['df']][2, 'a']")
go("x[['df']][2, 'b']")

yogat3ch/HDA documentation built on Sept. 13, 2019, 8:54 p.m.