R you ready for v4.0? Stats-lovers’ language hits ground running – but users will have to do their bit to keep up

R you ready for v4.0? Stats-lovers’ language hits ground running – but users will have to do their bit to keep up

Version 4.0 of the statistical computing language R is brimming with new features and ready to be installed – but this isn’t the only thing devs will have to do to get going with this major release.

Updating to the new version asks for some additional effort on the user’s side, since packages need to be re-installed under the new version. This is partly down to the R core team changing the standard behaviour of stringsAsFactors, which is now set to FALSE by default. Many packages however made use of the old behaviour when calling data.frame() and read.table(), so had to be changed accordingly.

Another change that makes re-installs necessary is the fact that the plot() S3 generic function has moved from the graphics to the base package. This also meant that packages defining S4 generics for plot() needed an update. Package devs are advised to also confirm that their creations import generics instead of relying “on their being looked for on the search path” as the release notes point out.

R 4.0 comes with a reworked way to specify _raw_ character constants, to facilitate writing strings with backslashes or quotes. The new syntax follows the pattern of r”(…)”, which could look familiar to C++ devs. The three dots are placeholders for any character sequence, though “) shouldn’t be part of it to make sure everything works as intended.

The release is however, brimful with new features, making the release notes well worth a look. Some examples include support for long vectors as the seq argument of a for() loop, a new function to register S3 methods in R scripts, a function list2DF() to create data frames from variable lists, or infoRDS() to help users get insight into the serialisation format of a serialised object.

Since apply was able to use dimnames as MARGIN arguments for “almost a decade”, sweep() and slice.index() finally follow suit in R 4.0. Users also gained a way of customising error messages through argument names,  a function to suggest “paths appropriate for storing R-related user-specific data, configuration and cache files”, and options to set up and handle server socket connections.

Developers using R on Windows will be pleased to learn Rterm now works when invoked from MSYS2 terminals and also includes an option to specify which workspace should be restored. On that operating system, R is now also able to resolve “symbolic links and normalizes case of long names of path elements in case-insensitive folders” in normalizePath(), and use md5sum() on UTF-8 file names no matter the native encoding.

The quite extensive list of new additions, bug fixes, and changes to the language can be found in the new release’s announcement message.