Appendix B. Other Things to Do in R

There are lots of things that R can do that didn’t make it into this book, either because they are niche requirements, because they’re too advanced, or because there are really good books out there already dealing with those topics. This appendix is intended to point you in the direction of further resources. Several of the subjects covered here are dealt with in more detail in the CRAN Task Views, which are well worth browsing.

You can make GUIs for your R code to help less technical users. The gWidgets framework allows high-level access to several graphics toolkits, including tcl/tk, qt, GTK2, and HTML. (Low-level access is also possible via tcltk/tcltk2, qtbase, RGtk2, and several HTML-generation packages.) Read Programming Graphical User Interfaces in R by Michael Lawrence and John Verzani for more information. The Java-based Deducer package provides an alternative, and RStudio’s shiny package makes it simple to make web apps with R.

You can call code in compiled languages (C, C++, and FORTRAN) via the .Call function. By far the easiest way of using these languages is to write C++ in conjunction with the Rcpp package. Read Seamless R and C++ Integration with Rcpp by Dirk Eddelbuettel for more on this subject.

R is single threaded, but there are several ways of making it use multiple cores or multiple machines to parallelize your code. The parallel package ships with R, and under POSIX-compliant operating systems (that’s most OSs that aren’t Windows) you can simply replace calls to lapply with mclapply to run loops over all the cores on your machine. Multicore capabilities using (MPI, SOCK, or other) socket-based clusters are possible using the snow and parallel packages. You can also connect to a Hadoop cluster using the RHIPE and rmr packages, or Hadoop in an Amazon Web Services using segue, not available for Windows. Read Parallel R by Q. Ethan McCallum and Stephen Weston for more details. The Enterprise edition of Revolution R has some parallelization features built into it.

The ff and bigmemory packages allow you to store R variables in files (like SAS does), avoiding the limitations of RAM. On a related note, the data.table package provides an enhanced data frame variable type that has faster indexing, assignment, and merging capabilities.

There are dozens of spatial statistics packages: sp provides a standard way of storing spatial data objects; maps, maptools, and mapproj provide helper functions for reading and writing maps; spatstat provides functions for (you guessed it) spatial statistics; OpenStreetMap retrieves raster images from http://openstreetmap.com; and so on.

Finally, R has a tool for combining code and output with regular text in a report (sometimes called literate programming or reproducible research), called Sweave. This has been improved upon and extended by the knitr package, which allows you to create reports using a variety of markup languages. In fact, this book was written using knitr to create AsciiDoc markup, which in turn was used to create PDF, HTML, and ebook documents. Yihui Xie’s Dynamic Documents with R and knitr explains how to use it.

The R ecosystem is big, and getting bigger all the time. These are just a few of the things that you might want to explore; take a look in the bibliography for some more ideas. Have fun exploring!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset