My book on R was published on 28 July 2020. The R package ‘learnrbook’ available through CRAN contains data and the R code scripts and chunks from the book. The book has now its own website.
In the book’s website you will find free supplementary chapters as downloadable PDF files and other material complementing the book.
[2022-06-24] Last week I started updating the book manuscript for a 2nd printing/edition. For the time being I have been adding several diagrams and flow charts, expanding the text to improve clarity and fixing all typos in text and code that I am aware of. I am also addressing the new features in R 4.2.0 and changes to the packages used in the examples. Please, do share with me anything you would like changed from the current edition and report any mistakes you may have found. All useful contributions will be acknowledged. Thanks in advance!
[2022-08-14] You may think that learning the ‘tidyverse’ could be enough. My experience tells it is not, and that a good understanding of the R language keeps one out of trouble even when using the ‘tidyverse’. I came accross an old post by Joel Spolsky that explains why this is the case in general: higher levels of abstractions “leak”, abstractions are imperfect, and the underlying complexity seeps through. With respect to R and the ‘tidyverse’, the evolving paper on Teaching R in a Kinder, Gentler, More Effective Manner by Norm Matloff is very clear about this.
[2022-08-24] The book has been listed as a “2021 CHOICE Outstanding Academic Title Award Winner” which makes me very happy and encourages my work on a 2nd edition.
Version 0.5.1 enhances the density based statistics with several new features without changing their default behaviour. The aim is to add flexibility better supporting the creation of annotated volcano and quadrant plots. These types of plots are frequently used to present gene transcript abundance estimates obtained by RNAseq or microarrays.
This update to ‘ggspectra’ tracks changes in ‘photobiology’ 0.10.15, ‘photobiologyWavebands’ 0.5.1 and ‘ggplot2’ 3.4.0, as well as in R 4.1.0. These are mostly deprecations that would trigger warnings. Please, be aware that these versions or later are now required.
The corrected definition of
PAR() in ‘photobiologyWavebands’ 0.5.1 is code breaking as this change will cause some plots, especially annotations in them to change, when
PAR() has been explicitly called in users’ code for quantities that are not photon based, in most cases with a warning.
New x scales and new functions for adding secondary x axes have been implemented.
PAR, or photosynthetically active radiation, as defined by McCree (1972) and used almost universaly in plant sciences is a biological spectral weighting function or BSWF that for spectral irradiance in photon based units takes one of two values for the weights: 0 or 1. So for computations of PAR photon irradiance (or PPFD) it is equivalent to integration over a range of wavelengths without application of a weighting function.
However, PAR, as defined by McCree, has a BSWF with weights that vary with wavelength when used to computed PAR (energy) irradiance, a quantity currently almost never used. Anyway the definition of the
PAR() waveband constructor in previous versions of the package was conceptually wrong, and has now been fixed. If anybody happened to compute PAR energy irradiance with earlier versions of the package, the results obtained were not weighted. This non-weighted quantity has been in the old literature occasionally also called PAR, but is a “PAR” quantity based on a different defintion than McCree’s. In the new version the result from the same computation is weighted, and differs from the one computed using earlier versions to an extent that depends on the shape of the spectrum.
One of the features of the package for a long time has been automatic wavelength interpolation when needed in computations involving two spectra. However, until the current version this behaviour did not extend to operations summarizing multiple spectra stored as members of the same collection, as inconsistent wavelength values triggered an error.
This update to ‘photobiology’ enhances the compatibility of ‘ggspectra’ with
spct objects that have been reduced in size by removal or “thinning” of intermediate wavelength values in rectilinear regions.
Spectra containing data for multiple spectra in long form were not well suported as members of
mspct collection objects, i.e., some operations available for collections without such members were unsupported.
These changes also enhance the compatibilty of package ‘ggspectra’ with the presence of inconsistent wavelengths across members of collections of spectra.
Version 0.5.2 fixes several bugs.
I have defined in package ‘ggpp’ enhanced versions of
geom_label() under the names of
geom_label_s() . The
s is for segment, at least it was when I thought of these names. The versions described are included in version 0.5.0.
The idea of better supporting the use of data labels in ggplots is not new. I have been for a long time a user of the repulsive geometries
geom_label_repel() from package ‘ggrepel’. I have even contributed some code to ‘ggrepel’. However, some time back when designing some new position functions, the idea of developing non-repulsive geometries suitable for data labels started growing on me.
Version 0.5.0 includes code-breaking enhancements to
geom_label_s(). The most significative is a mechanism to selectively applying aesthetics to different components of linked labels and text. This replaces the previous use of separate aesthetics applied only to segments or arrows. The reason behind this change is that segments are only links, and not meant to inform about data values on their own.
Version 0.2.6 is a maintenance update, fixing compatibility with recent versions of ‘dplyr’ and the just reelased ‘photobiology’ 0.10.14. It also includes minor enhancements to the interactive user interface (UI) of function
acq_irrad_interactive() . OceanInsight recently released version 2.70 of OmniDriver, and removed some functions from the API. For the time being, keep using version 2.56 that is known to work.
Recent and approaching code-breaking changes in the tidyverse packages ‘tidyselect’, ‘rlang’, ‘tidyr’, ‘dplyr’, ‘readr’ and ‘ggplot2’ meant that keeping my packages fully functional required changes to several of them. None of the changes in these packages made my packages fail CRAN checks, but they either made some functions unusable or triggered inumerable warnings in some use cases. In some cases the behaviour and warnings were weird and rather unpredictable, specially those due to the changes in ‘tidyselect’ version 1.2.0, which were also visible in ‘dplyr’ and ‘tidyr’. So below is a summary of my R-intensive week.
Version 0.4.25 fixed a bug affecting data exchange with package ‘colorSpec’. Version 0.4.26 fixes problems due to code-breaking changes in package ‘readr’. This version also adds support for importing data from PSI’s SpectraPen spectrometers.
This is a maintenance release, with minor enhancements and edits for compatibility with upcoming ‘ggplot2’ 3.4.0. The only highly visible change is in more clearly separating the roles of the debug statistics and the debug geom by setting
geom_null() as the default for the statistics.
Some of the code in this package is rather complex and contained syntax and constructs that were known for some time to be on their way to deprecation and removal in different packages from the ‘tidyverse’. Updating the package to the syntax used in current ‘ggplot2’ versions had been in my to do list for some time. Now the update had to be done, and it is now done.