For a .rda file, after loading it, except viewing it using Rtudio window, are there any functions that can list all the data information stored in this rda file?
Asked
Active
Viewed 547 times
1 Answers
0
When I want to see what's in an .rda
file without loading it into my current environment, I load it into a temp env:
e <- new.env(parent = emptyenv())
load("path/to/file.rda", envir=e)
ls(e) # shows names of variables stored in it
ls.str(e) # shows a `str` presentation of all variables within it
Not the most efficient way, as it requires that you load the contents before listing them. I don't think it's easy to look at a raw rda
file on-disk and know its contents without loading it in some fashion.

r2evans
- 141,215
- 6
- 77
- 149
-
I just load the rda file directly, for instance, temp<-load("x.rda"), then ls(temp). I got error message as Error in as.environment(pos) : no item called "X" on the search list – user297850 Mar 03 '21 at 04:03
-
I suggest you read `?load`, where its return value is a *"character vector of the names of objects created"*, and not the objects themselves. The premise of `load` is to operate in *side-effect* instead of a functional load of objects. If you want/need the ability to load an object directly such as that (without side-effect), then you may want `saveRDS` and `readRDS`, though it saves only one object instead of `save`'s ability to save zero or more objects into a single `.rda` file. – r2evans Mar 03 '21 at 13:14