Re: [R] opening RDB files

From: Henrik Bengtsson <hb_at_maths.lth.se>
Date: Fri 22 Jul 2005 - 02:52:14 EST

Emili Tortosa-Ausina wrote:
> Hi all,
>
> I've recently upgraded to R version 2.1.1 and when trying to inspect the
> contents of many packages in the library (for instance library\MASS\R) I've
> realized wordpad, or the notepad, won't open them since they have *.RDB and
> *.RDX extensions which these editors cannot recognize.
>
> However, libraries in previous versions of R did not have these extensions
> and I could inspect the contents of each package without any trouble.

The *.rdb etc are the new compact package file formats introduced around R v2.0.0; these are binary files that won't make much sense to look at.

   It was only in version before this you could inspect the R code by looking at the file <pkg>/R/<pkg>.R in a text file viewer/editor.

To look at the code now, you have to either download the source of the package you're interested in (look for the *.tar.gz files), or you can always do it from within R, e.g. print(read.table). If the the function you want to look at gives "UseMethod" and so on, you're looking at a generic function, e.g. print(print):

function (x, ...)
UseMethod("print")
<environment: namespace:base>

then you want to track down the method for your specific object. To find all implementation of "print", use methods(), e.g. methods(print):

   [1] print.acf*                       print.anova
   [3] print.aov*                       print.aovlist*
   [5] print.ar*                        print.Arima*
   [7] print.arima0*                    print.AsIs
   [9] print.Bibtex*                    print.by
<snip></snip>
[123] print.vignette*                  print.xgettext*
[125] print.xngettext*                 print.xtabs*

Then do, say, print(print.by) and you'll see the code. All method with an asterisk are namespace protected methods. To get these you have to use getAnywhere(), e.g. print(getAnywhere("print.acf")).

Why the new file format? It is used for package that utilized lazy loading, which more and more package now use (packages without lazy loading can still be inspected the "old" way). Thanks to lazy loading, packages now loads more or less instantainously. They are also more memory efficient, because all code is not loaded at once.

Cheers

Henrik Bengtsson

> I've been searching for this thread but did not find it.
>
> Thank you!
>
> Emili
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Jul 22 02:56:39 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:55 EST