The Journal - The R Journal - R Project

7 downloads 1421 Views 6MB Size Report
Jan 7, 2009 - Collaborative Software Development Using R-Forge . . . . . . . . . . . . . . . . . . . . . . . . 9 ... AdM
The

Journal Volume 1/1, May 2009

A peer-reviewed, open-access publication of the R Foundation for Statistical Computing

Contents Editorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3

Special section: The Future of R Facets of R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Collaborative Software Development Using R-Forge . . . . . . . . . . . . . . . . . . . . . . . .

5 9

Contributed Research Articles Drawing Diagrams with R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The hwriter Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . AdMit: Adaptive Mixtures of Student-t Distributions . . . . . . . . . . . . . . . . . . . . . . . expert: Modeling Without ). Furthermore, in the R Packages tab developers can examine logs of the build and check process on different platforms. To release a package to CRAN the project administrator clicks on Submit this package to CRAN in the R Packages tab. Upon confirmation, a message will be sent to [email protected] and the latest successfully built source package (the ‘.tar.gz’ file) is automatically copied to ftp://CRAN.R-project. org/incoming/. Note that packages are built once daily, i.e., the latest source package does not include more recent code committed to the SVN repository. Figure 3 shows the R Packages tab of the tm project (http://R-Forge.R-project.org/projects/ tm/) as one of the project administrators would see it. Depending on whether you are a member of the project or not and your rights you will see only parts of the information provided for each package.

Further steps A customized project website, accessible through http://foo.R-Forge.R-project.org/ where foo corresponds to the unix name of the project, is managed via the ‘www’ directory. The website gets updated every hour. The changes made to the project can be examined by entering the corresponding standardized web area. On entry, the Summary page is shown. Here, one can • examine the details of the project including a short description and a listing of the administrators and developers, • follow a link leading to the project homepage,

13

Recent and future developments In this section, we briefly summarize the major changes and updates to the R-Forge system during the last few months and give an outlook to future developments. Recently added features and major changes include: • New defaults for freshly registered projects: Only the tabs Lists, SCM and R packages are enabled initially. Forums, Tracker and News can be activated separately (in order not to overwhelm new users with too many features) using Edit Public Info in the Admin tab of the project. Experienced users can decide which features they want and activate them. • An enhanced structure in the SVN repository allowing multiple packages in a single project (see above). • The R package RForgeTools (Theußl, 2009) contains platform-independent package building and quality management code used on the R-Forge servers. • A modified News submit page offering two types of submissions: project-specific and global news. The latter needs approval by one of the R-Forge administrators (default: projectonly submission). • Circulation of SVN commit messages can be enabled in the SCM Admin tab by project administrators. The mailing list mentioned in the text field is used for delivering the SVN commit messages (default: off). • Mailing list search facilities provided by the Swish-e engine which can be accessed via the List tab (private lists are not included in the search index). Further features and improvements which are currently on the wishlist or under development include • a Wiki,

• examine the latest news announcements (if available),

• task management facilities,

• go to other sections of the project like Forums, Tracker, Lists, R Packages, etc.

• a re-organized tracker more compatible with R package development and,

• follow the download link leading directly to the available packages of the project (i.e., the R Packages tab).

• an update of the underlying GForge system to its successor FusionForge (http:// FusionForge.org/).

Furthermore, meta-information about a project can be supplied in the Admin tab via so-called “Trove Categorization”.

For suggestions, problems, feature requests, and other questions regarding R-Forge please contact [email protected].

The R Journal Vol. 1/1, May 2009

ISSN 2073-4859

14

I NVITED S ECTION : T HE F UTURE OF R

Figure 3: R Packages tab of the tm project

Acknowledgments Setting up this project would not have been possible without Douglas Bates and the University of Wisconsin as they provided us with a server for hosting this platform. Furthermore, the authors would like to thank the Computer Center of the Wirtschaftsuniversität Wien for their support and for providing us with additional hardware as well as a professional server infrastructure.

Bibliography P. Cederqvist et al. Version Management with CVS. Network Theory Limited, Bristol, 2006. Full book available online at http://ximbiot.com/ cvs/manual/. T. Copeland, R. Mas, K. McCullagh, T. Perdue, G. Smet, and R. Spisser. GForge Manual, 2006. URL http://gforge.org/gf/download/ docmanfileversion/8/1700/gforge_manual.pdf. C. M. Pilato, B. Collins-Sussman, and B. W. Fitzpatrick. Version Control with Subversion. O’Reilly,

The R Journal Vol. 1/1, May 2009

2004. Full book available online at http:// svnbook.red-bean.com/. R-Forge Administration and Development Team. RForge User’s Manual, 2008. URL http://download. R-Forge.R-project.org/R-Forge.pdf. E. S. Raymond. The Cathedral and the Bazaar. Knowledge, Technology, and Policy, 12(3):23–49, 1999. S. Theußl. RForgeTools: R-Forge Build and Check Tools, 2009. URL http://R-Forge.R-project.org/ projects/site/. R package version 0.3-3. Stefan Theußl Department of Statistics and Mathematics WU Wirtschaftsuniversität Wien Austria [email protected] Achim Zeileis Department of Statistics and Mathematics WU Wirtschaftsuniversität Wien Austria [email protected]

ISSN 2073-4859

C ONTRIBUTED R ESEARCH A RTICLES

15

Drawing Diagrams with R by Paul Murrell R provides a number of well-known high-level facilities for producing sophisticated statistical plots, including the “traditional” plots in the graphics package (R Development Core Team, 2008), the Trellisstyle plots provided by lattice (Sarkar, 2008), and the grammar-of-graphics-inspired approach of ggplot2 (Wickham, 2009). However, R also provides a powerful set of lowlevel graphics facilities for drawing basic shapes and, more importantly, for arranging those shapes relative to each other, which can be used to draw a wide variety of graphical images. This article highlights some of R’s low-level graphics facilities by demonstrating their use in the production of diagrams. In particular, the focus will be on some of the useful things that can be done with the low-level facilities provided by the grid graphics package (Murrell, 2002, 2005b,a).

Starting at the end An example of the type of diagram that we are going to work towards is shown below. We have several “boxes” that describe table schema for a ) > grid.text("title", x=unit(2, "mm"), y=unit(0.5, "lines"), just="left") > popViewport()

ISBN title

Coordinate systems The positioning of the labels within the viewport in the previous example demonstrates another useful feature of the grid graphics system: the fact that locations can be specified in a variety of coordinate systems or units. In that example, the text was positioned horizontally in terms of millimetres and vertically in terms of lines of text (which is based on the font size in use). As another example of the use of these different units, we can size the overall viewport so that it is just the right size to fit the text labels. In the following code, the height of the viewport is based on the The R Journal Vol. 1/1, May 2009

number of labels and the width of the viewport is based on the width of the largest label, plus a 2 mm gap either side. This code also simplifies the labelling by drawing both labels in a single grid.text() call. > labels vp pushViewport(vp) > grid.roundrect() > grid.text(labels, x=unit(2, "mm"), y=unit(2:1 - 0.5, "lines"), just="left") > popViewport()

ISBN title

Clipping Another feature of the boxes that we want to produce is that they have shaded backgrounds. Looking closely, there are some relatively complex shapes involved in this shading. For example, the grey background for the “heading” of each box has a curvy top, but a flat bottom. These are not simple rounded rectangles, but some unholy alliance of a rounded rectangle and a normal rectangle. It is possible, in theory, to achieve any sort of shape with R because there is a general polygon graphical primitive. However, as with the positioning of the text labels, determining the exact boundary of this polygon is not trivial and there are easier ways to work. In this case, we can achieve the result we want using clipping, so that any drawing that we do is only visible on a restricted portion of the page. R does not provide clipping to arbitrary regions, but it is possible to set the clipping region to any rectangular region. The basic idea is that we will draw the complete rounded rectangle, then set the clipping region for the box viewport so that no drawing can occur in the last line of text in the box and then draw the rounded rectangle again, this time with a different background. If we continue doing this, we end up with bands of different shading. The following code creates an overall viewport for a box and draws a rounded rectangle with a grey fill. The code then sets the clipping region to start one line of text above the bottom of the viewport and draws another rounded rectangle with a white fill. The effect is to leave just the last line of the original ISSN 2073-4859

C ONTRIBUTED R ESEARCH A RTICLES

17

grey rounded rectangle showing beneath the white rounded rectangle that has had its last line clipped. > pushViewport(viewport(width=.25)) > grid.roundrect(gp=gpar(fill="grey")) > grid.clip(y=unit(1, "lines"), just="bottom") > grid.roundrect(gp=gpar(fill="white")) > popViewport()

> > > > > >

Drawing curves Another basic shape that is used in the overall diagram is a nice curve from one box to another. In addition to the basic functions to draw straight lines in R, there are functions that draw curves. In particular, R provides a graphical primitive called an X-spline (Blanc and Schlick, 1995). The idea of an Xspline is that we define a set of control points and a curve is drawn either through or near to the control points. Each control point has a parameter that specifies whether to create a sharp corner at the control point, or draw a smooth curve through the control point, or draw a smooth curve that passes nearby. The following code sets up sets of three control points and draws an X-spline relative to each set of control points. The first curve makes a sharp corner at the middle control point, the second curve makes a smooth corner through the middle control point, and the third curve makes a smooth corner near the middle control point. The control points are drawn as grey dots for reference (code not shown). > > > > > > > > >

x1 > > + + + > +

### Empirical Mode Decomposition par(mfrow=c(3,1), mar=c(2,1,2,1)) try