How can I view all the hidden/internal variables of an R package within an R session?
By hidden/internal variables I mean the sort of variables described in R Packages - External Data which would be stored in the "/pkg/R/sysdata.Rda" file of a package's source code.
My attempts below. None of these are quite right. I feel like I'm missing something. There has to be a straightforward way to do this, right?
Of course, I can download the package source and
load(file.path("pkg","R","sysdata.Rda"))
But that would involve work outside my session, which doesn't work for me.
:::
Within an RStudio R session, I could do
> library(pkg)
> pkg:::
where RStudio auto-suggests what to include after the :::
. Among the suggestions, it shows all internal variables. This is a decent hack. But I'd like something a little cleaner, which doesn't depend on RStudio's auto-suggestions.
.rdx
and .rdb
files?I noticed
pkg/R/sysdata.rdx
pkg/R/sysdata.rdb
in the package binaries. I thought I might be able to read these to display all the internal variables. How to open .rdb file using R has an answer which relies on lazyLoad
. But I wasn't able to get this working. And it seems others weren't either.
You can get all of the functions (exported and unexported) with ls
and asNamespace
:
head(ls(envir = asNamespace('data.table')))
# [1] "-.IDate" ":=" "[.data.table" "[.ITime"
# [5] "[<-.data.table" "[<-.IDate"
I'm not positive about your latter point, but I thing system.file
has what you want. IIRC anything else that gets installed with the package should be in this location.
head(list.files(system.file(package = 'data.table'), recursive = TRUE))
# [1] "DESCRIPTION" "help" "html" "INDEX" "libs"
# [6] "LICENSE"