05.12.2012 Views

What documentation exists for R?

What documentation exists for R?

What documentation exists for R?

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 8: R Programming 91<br />

8 R Programming<br />

8.1 How should I write summary methods?<br />

Suppose you want to provide a summary method <strong>for</strong> class "foo". Then summary.foo()<br />

should not print anything, but return an object of class "summary.foo", and you should<br />

write a method print.summary.foo() which nicely prints the summary in<strong>for</strong>mation and<br />

invisibly returns its object. This approach is preferred over having summary.foo() print<br />

summary in<strong>for</strong>mation and return something useful, as sometimes you need to grab something<br />

computed by summary() inside a function or similar. In such cases you don’t want<br />

anything printed.<br />

8.2 How can I debug dynamically loaded code?<br />

Roughly speaking, you need to start R inside the debugger, load the code, send an interrupt,<br />

and then set the required breakpoints.<br />

See section “Finding entry points in dynamically loaded code” in Writing R Extensions.<br />

8.3 How can I inspect R objects when debugging?<br />

The most convenient way is to call R_PV from the symbolic debugger.<br />

See section “Inspecting R objects when debugging” in Writing R Extensions.<br />

8.4 How can I change compilation flags?<br />

Suppose you have C code file <strong>for</strong> dynloading into R, but you want to use R CMD SHLIB with<br />

compilation flags other than the default ones (which were determined when R was built).<br />

Starting with R 2.1.0, users can provide personal Makevars configuration files in<br />

‘$HOME/.R’ to override the default flags. See section “Add-on packages” in R Installation<br />

and Administration.<br />

For earlier versions of R, you could change the file ‘$R_HOME/etc/Makeconf’ to reflect<br />

your preferences, or (at least <strong>for</strong> systems using GNU Make) override them by the environment<br />

variable MAKEFLAGS. See section “Creating shared objects” in Writing R Extensions.<br />

8.5 How can I debug S4 methods?<br />

Use the trace() function with argument signature= to add calls to the browser or any<br />

other code to the method that will be dispatched <strong>for</strong> the corresponding signature. See<br />

?trace <strong>for</strong> details.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!