ggpmisc 0.2.0 (1st preview: new package)

I wrote this currently small package to hold ggplot2 extensions which can be useful for plotting data and/or can serve as examples of how to write such extensions for ggplot2 (>= 2.0.0).

At the moment it contains for statistics:

stat_debug() just echos to a label on the plot information on the data for a group. I wrote it for debugging and better understanding what data was being passed to an stat I was writing.

stat_poly_eq() can be used to add to a plot the equation corresponding to a fit of a polynomial of any degree returned by lm(). By default it only adds r2 as this value will be valid even if the fitted model was not a polynomial.

stat_peaks() and stat_valleys() are versions of the statistics of the same names in package photobiology simplified so as to work with x and y data that are simply numeric, rather than requiring spectra.

The user Guide includes code examples with explanations but some of the statistics added today lack examples.

Please, report any problems you encounter, and suggest possible changes or additions to the functionality!

NOTE: Sources, and Windows binaries for R 3.2.x, are now available in the R-test repository.

R tips 1: playing with polynomials

Polynomial equation as annotation
Polynomial equation as annotation to a ggplot.

I have collected some code snippets I used recently for working with polynomials. The idea of writing this page came from a question I was asked a few days ago by Titta Kotilainen. I should emphasize that the page linked below concerns only polynomials, and excludes all other linear models that can be fit with lm(). Even models that are polynomials but formulated not as a regular polynomial equation (e.g. x ~ I(x^2) + x instead of the expected x + I(x^2) will quietly fail! In contrast, use of poly() as in y ~ poly(x, 2) is fine.

I used Rmarkdown in RStudio to generate a page with knitted examples, if interested the source file is also available.


Two builds and two repositories

The repositories

I will keep from now on two CRAN-like repositories at this site. The one that has been in use for some time will remain in use, but I will only upload to it the stable and well tested versions of the packages.

I have just created a second repository with address R_test instead of R where I will keep the latest versions. This adds a slight complication, but will allow a smoother update process and give a more clear way of choosing the degree of novelty desired.

Releases at

Previews at (Path to repository updated on 7.01.2016!)

I have just uploaded to the “test” repository the result of recent weeks’ work and in particular the updates I did over the weekend to track the update of ggplot2 to version 2.0.0. Package photobiologygg has been replaced by a new package that I wrote over the weekend. The new is called ggspectra. I have re-implemented quite much of the functionality of the old package but there is still work to do on the waveband annotations which will become ggplot statistics. I have added a few new features to the stats I am re-writing which simplify their use, thanks to the improvements to package ggplot2. There are also quite a few improvements in ggplot2itself to facet labelling and even a couple of new geoms and stats have been added to version 2.0.0 of ggplot2. However, in the days since its release a few bugs have been found, and one of them interferes with the proper testing and to some extent use of the stats that I am writing, so if you can, wait a few days until ggplot2 2.0.1 is released. The problem I had was my own misunderstanding about how to create new ggplot statistics!

Future releases and previews

In posts, the released versions will be shown in blue as earlier, and the preview (=test) versions in orange, like this:

photobiology 0.9.0 (release: bug fix, new features)

Description of changes

NOTE: Sources, and Windows binaries for R 3.2.x, are now available in the R repository.

photobiology 0.9.1 (preview: bug fix, new features)

Description of changes

NOTE: Sources, and Windows binaries for R 3.2.x, are now available in the R-test repository.

Back to Top