haotu : an open lab notebook

2014/02/05

R ls() search

Filed under: R — Tags: , , , — S @ 02:31
ls(pattern="tree")

From

x <- 1:10
f <- function() ls()
g <- function() ls(envir=.GlobalEnv)
h <- function() ls(envir=.GlobalEnv, pattern="[fg]")
f()
# character(0)
g()
# [1] "f" "g" "h" "x"
h()
# [1] "f" "g"

http://stackoverflow.com/questions/8142941/how-to-search-an-environment-using-ls-inside-a-function

Advertisements

Create a free website or blog at WordPress.com.