The Mark Fredrickson blog has a superb post on R functions and environments that's well worth checking out.
He also includes a handy function for debugging:
> fnpeek <- function(f, name = NULL) {
+ env <- environment(f)
+ if (is.null(name)) {
+ return(ls(envir = env))
+ }
+ if (name %in% ls(envir = env)) {
+ return(get(name, env))
+ }
+ return(NULL)
+ }
> fnpeek(f1)
[1] "n"
> fnpeek(f1, "n")
[1] 7
Monday, February 7, 2011
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment