Skip to content
Prev 359350 / 398502 Next

How to reach the column names in a huge .RData file without loading it

Barry: that's an interesting hack.

I do feel compelled to make two comments, though, regarding the
general issue rather than the scraping idea:

(1) If your situation is that that image (.RData file) is the only
copy of the data, you'll need to rescue the data from that as soon as
possible anyway. Something like

    load(".RData");
    write.csv(mydataframe, file = "mydata.csv");

should do this trick. It will be slow, but you'll need to do it just
once, so you might as well enjoy your coffee while you wait. From that
point on, work with the mydata.csv file for getting at the colnames
(and anything else as well).

(2) If there's any chance / risk that scraping data off images is not
a one-off, the time to prevent that from catching on is now. If data is
of any value at all, it should be handled in a sane, portable, textual
format. For tabular data, csv is normally adequate or at least good
enough, but .RData images are never a good idea.

Best regards, Jan

P.S.: I've seen .RData images containing many months worth of interactive
work, and multiple variants of data frames in variables with more or less
similar names, so the set of strings scraped off these will be rather more
bewildering than in Barry's clean example.
On Wed, Mar 16, 2016 at 05:17:25PM +0000, Barry Rowlingson wrote: