[R] foo.RData or foo.r?

Jason Turner jasont at indigoindustrial.co.nz
Fri Oct 3 21:30:03 CEST 2003


Federico Calboli wrote:
> On Fri, 2003-10-03 at 13:16, Adaikalavan RAMASAMY wrote:
> 
>>*.R is for the script file and is ASCII type.
>>*.Rdata (or sometimes *.rda) is the usual extension for R data and
>>contains binary information.
>>
>>If you try to cat a *.Rdata file, you will end up with gibberish as it
>>is binary.
>>
>>Try opening *.Rdata with emacs if you can. Emacs will recognise it as a
>>fundamental type and not as an ESS type. There might be ways to
>>associate Rdata files with ESS. But other people might not consider
>>reading your "*.Rdata" files.
>>
> 
> I dunno about this, but if I open R under emacs first and then I load my
> foo.RData, it loads fine.

By "fine", you mean it looks like normal R code?

On Un*x systems(including Linux), the extension is a matter of 
convenience, not necessity.  It's possible to save your R code, 
transcripts, etc with any extension you want (.R, .S, or even silly 
things, like .exe if you want).  And Emacs will still cheerfully read 
them just fine.

However, just because you *can*, doesn't mean you *should* ;)

There is a *convention* in R that workspace images or saved objects 
(using save.image() or save() ) should have filenames that end in .RData 
.  R code should have filenames that end in .R .  This isn't necessary, 
but it helps keep things tidy and easy to organise.  ESS also has some 
built-ins to recognise .R as R code, so it can do nice things like 
highlight syntax, indent well, and send code to an R session to be 
evaluated.

Short answer:  anything that's R code *should* be named with .R at the 
end.  Anthing R created after you told it save() or save.image() or 
answered "y" to the "Save workspace image" question *should* have a name 
ending with .RData .  None of this is strictly necessary, but there are 
a bunch of nice things that happen if you do.

Clear as mud?  ;)

Cheers

Jason
-- 
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
jasont at indigoindustrial.co.nz




More information about the R-help mailing list