## Time series plots in R

#### 23 October 2013 /posted in: r

I recently coauthored a couple of papers on trends in environmental data (Curtis & Simpson in press; Monteith et al. in press), which we estimated using GAMs. Both papers included plots like the one shown below wherein we show the estimated trend and associated point-wise 95% confidence interval, plus some other markings. The coloured sections show where the estimated trend is changing in a statistically significantly manner, i.e. where a 95% confidence interval on the first derivative (rate of change) of the trend does not include 0. That particular figure and the others in the papers were drawn using the lattice package (Sarkar 2008), but I could just have easily used ggplot2 (Wickham 2009) instead. I was recently asked via email how I produced the figures in the paper. Rather than just reply to that email, I thought I’d knock up a quick post for my blog to show how it was done.

Curtis C.J. & Simpson G.L. et al. (in press) Trends in bulk deposition of acidity in the UK, 1988–2007, assessed using additive models. Ecological Indicators.

Monteith D.T., Evans C.D., Henrys P.A., Simpson G.L. & Malcolm I.A.et al. (in press) Trends in the hydrochemistry of acid-sensitive surface waters in the UK 1988–2008. Ecological Indicators.

Sarkar D. et al. (2008) Lattice: Multivariate Data Visualization with R. Springer, New York.

Wickham H. et al. (2009) ggplot2: elegant graphics for data analysis. Springer New York.

## Using Arial in R figures destined for PLOS ONE

#### 09 September 2013 /posted in: r

Despite the refreshing change that the journal PLOS ONE represents in terms of open access and an refreshing change to the stupidity that is quality/novelty selection by the two or three people that review a paper, it’s submission requirements are far less progressive. Yes they make you jump through a lot of hoops getting your figures and tables just so, and I can appreciate why they want some control over this in terms of the look and feel of the journal. A couple of things grate though:

## Open data and Ecology

#### 27 August 2013 /posted in: science

Open science was present in good order at the recent ESA meeting in Minneapolis. Much of what was being discussed under that broadest of headings, open science, was the reproducibility of the science we do and one critical aspect of this is free, open access to data. Openly sharing data that underlie research publications is a rapidly-developing area of the scientific landscape faced today by scientists, not just ecologists; many journals now require data that support research papers be deposited under a permissive licence in approved repositories, such as Dryad or figshare, and a number of journals have been founded specifically to cater for the publication of data papers, including Ubiquity Press’ the Journal of Open Archeological Data, Nature Publishing Group’s forthcoming Scientific Data, and Wiley’s Geoscience Data Journal. Unfortunately, ecologists are more likely to be known for the iron-like grip with which the cling to their hard-won data. Into this landscape, Stephanie Hampton and colleagues (Hampton et al. 2013) published (it’s been online for a few months) a paper in Frontiers in Ecology and Environment; Big data and the future of ecology

Hampton S.E., Strasser C.A., Tewksbury J.J., Gram W.K., Budden A.E. & Batcheller A.L.et al. (2013) Big data and the future of ecology. Frontiers in Ecology and the Environment 11, 156–162.

## Flickering diatoms?

#### 16 July 2013 /posted in: science

Last year, Rong Wang and colleagues (Wang et al. 2012) published a very nice paper in Nature, which claimed to have observed flickering, an early warning indicator of an approaching critical transition, in a diatom sediment sequence from Erhai Lake, Yunnan, China. What was particularly pleasing about this paper was that the authors had tried to use the sediment record to investigate whether we see signs of early warning indicators prior to a transition between stable states. It was refreshing to not see a transfer function!

Wang R., Dearing J.A., Langdon P.G., Zhang E., Yang X. & Dakos V.et al. (2012) Flickering gives early warning signals of a critical transition to a eutrophic lake state. Nature 492, 419–422.

## Decluttering ordination plots part 3: ordipointlabel()

#### 27 June 2013 /posted in: r

Previously in this series I looked at first the ordilabel() and then orditorp() functions in the vegan package as means to improve labelling in ordination plots. In this the third in the series I take a look at ordipointlabel().

## Decluttering ordination plots in vegan part 2: orditorp()

#### 13 January 2013 /posted in: r

In the earlier post in this series I looked at the ordilabel() function to help tidy up ordination biplots in vegan. An alternative function vegan provides is orditorp(), the last four letters abbreviating the words text or points. That is a pretty good description of what orditorp() does; it draws sample or species labels using text where there is room and where there isn’t a plotting character is drawn instead. Essentially it boils down to being a one stop shop for calls to text() or points() as needed. Let’s see how it works…

## Decluttering ordination plots in vegan part 1: ordilabel()

#### 12 January 2013 /posted in: r

In an earlier post I showed how to customise ordination diagrams produced by our vegan package for R through use of colours and plotting symbols. In a series of short posts I want to cover some of the options available in vegan that can be used to help in producing better, clearer, less cluttered ordination diagrams. First up we have ordilabel().

## Shading regions under a curve

#### 11 January 2013 /posted in: r

Over on the Clastic Detritus blog, Brian Romans posted a nice introduction to plotting in R. At the end of his post, Brian mentioned he would like to colour in areas under the data curve corresponding to particular ranges of grain sizes. The comment area on a blog isn’t really amenable to giving a full answer to the problem posed so I gave a few pointers. Other commenters also suggested solutions.

The problem is how to shade or colour in areas under a curve. The more general problem is how to do this when you don’t have any data that fall on the margins of the regions you wish to shade. Here is more solution to that more general problem.

## Monotonic deshrinking in weighted averaging models

#### 05 January 2013 /posted in: r

Weighted averaging regression and calibration is the most widely used method for developing a palaeolimnological transfer function. Such models are used to reconstruct properties of the past lake environment such as pH, total phosphorus, and water temperature with, it has to be said, varying degrees of success and usefulness.

In simple weighted averaging (WA) there is little to specify other than the predictors (the species or other proxy data) and the response (the thing you wish to build a model for and predict). The one user-specified option in a simple WA is the type of deshrinking to use.

Why deshrinking?

## A new version of analogue for a new year

#### 04 January 2013 /posted in: r

Yesterday I rolled up a new version (0.10-0) of analogue, my R package for analysing palaeoecological data. It is now available from CRAN. There were lots of incremental changes to Stratiplot() to improve the quality of the stratigraphic diagrams produced and fix several annoying bugs. Also the definition of the standard error of MAT reconstructions was fixed; it is essentially a weighted variance but the original version assumed the weights summed to 1, which is not the case for dissimilarities of the k-NN. Several new functions and additional functionality were added to the package.