exists(x)

Check if an R object exists in the current session. Functions and data objects from the base or other packages may also be checked.

- x – The name of an R object as a character string.

Example. I grab a few variables from yesterday’s post, then I look for a few variables, one of which doesn’t exists, and then several functions.

> > #______ Code From Yesterday ______# > x1 <- c(52938, 1928, 12, 2, 0.0053) > x2 <- c(52938, 1928, 12, 2, 0.005) > y <- c(52938, 1928, 12, 2, 0) > > exists("x1") [1] TRUE > exists("x2") [1] TRUE > exists("x3") [1] FALSE > > #______ Look For Functions ______# > exists("all") [1] TRUE > exists("getReturns") [1] FALSE > > library(stockPortfolio) > exists("getReturns") [1] TRUE >

The all function has its own post. I’ll cover the getReturns function in a future post.