Skip to content

Instantly share code, notes, and snippets.

@TobCap
Created August 28, 2013 10:37
Show Gist options
  • Select an option

  • Save TobCap/6364664 to your computer and use it in GitHub Desktop.

Select an option

Save TobCap/6364664 to your computer and use it in GitHub Desktop.
f <- function(x) x + 1
str(f)
attributes(f)
str((attr(f, "srcref")))
class((attr(f, "srcref")))
attributes((attr(f, "srcref")))
attr((attr(f, "srcref")), "srcfile") # environment
attr((attr(f, "srcref")), "class") # string
ls.str(attr((attr(f, "srcref")), "srcfile"))
ls.str(utils:::getSrcfile(f))
tmp.path <- file.path(tempdir(), "test.r")
cat("g <- function(x) x - 1", file = tmp.path)
source("test.r")
str(g)
attributes(g)
str((attr(g, "srcref")))
class((attr(g, "srcref")))
attributes((attr(g, "srcref")))
attr((attr(g, "srcref")), "srcfile") # environment
attr((attr(g, "srcref")), "class") # string
ls.str(attr((attr(g, "srcref"c)), "srcfile"))
ls.str(utils:::getSrcfile(g))
getParseData(g)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment