Skip to content

names of objects in .rda

7 messages · Benilton Carvalho, Duncan Murdoch, Douglas Bates +3 more

#
Hi everyone,

sorry if this was discussed before (and in this situation, could you  
please point me to the discussion in the archive? My search didn't  
seem to be effective).

Is there a way of getting the names of objects in a .rda file without  
having to load it?

Thank you very much,

benilton

--
PhD Candidate
Department of Biostatistics
Bloomberg School of Public Health
Johns Hopkins University
#
On 5/11/2007 11:53 AM, Benilton Carvalho wrote:
Not currently, but it would be a nice little project for someone to 
write that, and also code to help retrieve objects from a .rda file 
after it had been damaged and was no longer loadable by R.  My normal 
advice would be not to use .rda files to save things, but sometimes the 
alternatives are not nearly as convenient.

Duncan Murdoch
#
An approach would be to attach it and then use ls() 

attach(myarchive.rda)
ls(pos=2) 
detach(myarchive.rda)

-Christos

Christos Hatzis, Ph.D.
Nuvera Biosciences, Inc.
400 West Cummings Park
Suite 5350
Woburn, MA 01801
Tel: 781-938-3830
www.nuverabio.com
#
On 5/11/07, Benilton Carvalho <bcarvalh at jhsph.edu> wrote:
Although it is not terribly different from loading an .rda file you
can get the names of the objects via the sequence

objects(attach("myRdaFile.rda")); detach()
#
On Fri, 11 May 2007, Benilton Carvalho wrote:

            
Well, of course there is a way (R has ways to read datafiles from other 
packages, and similarly one could write a .rda reader from the description 
in 'R Internals').

First, .rda files exist in several different formats, so you would have to 
open it to get the format or assume the most recent format.

Second, the internal structure is as a pairlist (a pairlist is constructed 
and that single object saved), and you are asking for the tags of the 
pairlist.  Those are distributed throughout the file, so you would need to 
know a great deal about the structure to read the file without making use 
of R's internals.

I wonder what motivates the question: loading into a new enviroment is 
pretty painless and returns a character vector of object names.  It is 
possible that the file would be too big to do so, but then knowing what is 
in it is not going to help as there is no way to extract just part of it 
(and R objects are not in any case self-contained and may share 
sub-objects).
#
"Christos Hatzis" <christos at nuverabio.com> writes:
No, that really is not an approach.  If you load it, then there is no
problem to read the names.  The point is not to load it.  This is
important when dealing with large objects or large collections of
objects.

+ seth
#
You're right.  I didn't realize that what happens when attaching is that

"a new environment is created on the search path and the elements of a list
(including columns of a data frame) or objects in a save file or an
environment are *** copied *** into the new environment" 

Thanks.
-Christos