packBits(bits, type="double") newly works as inverse of numToBits() , thanks to Bill Dunlap's proposal in PR#17914 .

capture.output() no longer uses NSE to evaluate its arguments. This makes evaluation of functions like parent.frame() more consistent, thanks to Lionel Henry's PR#17907 .

...elt() now propagates visibility consistently with ..n , thanks to Lionel Henry's PR#17905 .

c() now removes NULL arguments before dispatching to methods, thus simplifying the implementation of c() methods, but for back compatibility reasons keeps NULL when it is the first argument; from a report and patch proposal by Lionel Henry in PR#17900 .

For HTML help (both dynamic and static), Rd file links to help pages in external packages are now treated as references to topics rather than file names, and falls back to a file link only if the topic is not found in the target package. The earlier rule which prioritized file names over topics can be restored by setting the environment variable _R_HELP_LINKS_TO_TOPICS_ to a false value.

path.expand() can expand ~user on most Unix-alikes even when readline is not in use. It tries harder to expand ~, for example should environment variable HOME be unset.

Functions URLencode() and URLdecode() in package utils now work on vectors of URLs. Based on patch from Bob Rudis submitted with PR#17873 .

New functions numToBits() and numToInts() extend the raw conversion utilities to (double precision) numeric .

checkRdContents() is now exported from tools; it and also checkDocFiles() have a new option chkInternal allowing to check Rd files marked with keyword "internal" as well. The latter can be activated for R CMD check via experimental environment variable _R_CHECK_RD_INTERNAL_TOO_.

Rudimentary support for vi-style tags in rtags() and R CMD rtags , based on patch from Neal Fultz in PR#17214 .

str(xS4) now also shows extraneous attributes of an S4 object xS4 .

capabilities() gets new entry "Rprof" which is TRUE when R has been configured with the equivalent of --enable-R-profiling (as it is by default): related to Michael Orlitzky's report PR#17836 .

Unicode character width tables (as used by nchar(, type="w") ) have been updated to Unicode 12.1 by Brodie Gaslam ( PR#17781 ).

When printing list arrays, classed objects are now shown via their format() value if this is a short enough character string, or by giving the first elements of their class vector and their length.

type.convert() now warns when its as.is argument is not specified, as the help file always said it should. In that case, the default is changed to TRUE in line with its change in read.table() (related to stringsAsFactor ) in R 4.0.0.

New ...names() utility, complementing others, proposed by Neal Fultz in PR#17705 .

The format() method for class "ftable" gets a new option justify ; suggested by Thomas Soeiro.

Using c() to combine a factor with other factors now gives a factor, and specifically an ordered factor when combining ordered factors with identical levels.

The checking of the size of tarball in R CMD check --as-cran <pkg> may be tweaked via the new environment variable _R_CHECK_CRAN_INCOMING_TARBALL_THRESHOLD_, as suggested in PR#17777 by Jan Gorecki.

package_dependencies() (in package tools) can now use different dependency types for direct and recursive dependencies.

www.omegahat.net is no longer one of the repositories known by default to setRepositories() . (Nowadays it only provides source packages and is often unavailable.)

These new features are only supported (so far) on Cairo graphics devices and the pdf() device.

The grid package now allows gpar(fill) to be a linearGradient() , a radialGradient() , or a pattern() . The viewport(clip) can now also be a grob, which defines a clipping path, and there is a new viewport(mask) that can also be a grob, which defines a mask.

The clipping that the graphics engine does perform (for both canClip = TRUE and canClip = FALSE ) has been improved to avoid producing unnecessary artifacts in clipped output.

Graphics devices can now specify canClip = NA_LOGICAL , in which case the graphics engine will never perform any clipping of output itself.

The graphics engine version, R_GE_version , has been bumped to 13 and so packages that provide graphics devices should be reinstalled.

The standalone ‘libRmath’ math library and R 's C API now provide log1pexp() again as documented, and gain log1mexp() .

configure checks for a program pkgconf if program pkg-config is not found. These are now only looked for on the path (like almost all other programs) so if needed specify a full path to the command in PKG_CONFIG , for example in file ‘config.site’.

Packages can opt in or out of LTO compilation via a UseLTO field in the ‘DESCRIPTION’ file. (As usual this can be overridden by the command-line flags.)

R CMD INSTALL and R CMD SHLIB have a new flag --use-LTO to use LTO when compiling code, for use with R configured with --enable-lto=R. For R configured with --enable-lto, they have the new flag --no-use-LTO.

Configuring with flag --enable-lto=R now also uses LTO when installing the recommended packages.

There is experimental support for cross-building R packages with C, C++ and/or Fortran code.

There is support for cross-compiling the C and Fortran code in R and standard packages on suitable (Linux) platforms. This is mainly intended to allow developers to test later versions of compilers – for example using GCC 9.2 or 10.x has detected issues that GCC 8.3 in Rtools40 does not.

R can be built with Link-Time Optimization with a suitable compiler – doing so with GCC 9.2 showed several inconsistencies which have been corrected.

There is a new text file ‘src/gnuwin32/README.compilation’, which outlines how C/Fortran code compilation is organized and documents new features:

for GCC >= 8, FC_LEN_T is defined in ‘config.h’ and hence character lengths are passed from C to Fortran in inter alia BLAS and LAPACK calls.

This provides a valuable check on code consistency. It does work with GCC 8.3 as in Rtools40, but that does not detect everything the CRAN checks with GCC 10 do.

R CMD INSTALL and R CMD SHLIB make use of their flag --use-LTO when the LTO_OPT make macro is set in file ‘etc/${R_ARCH}/Makeconf’ or in a personal/site ‘Makevars’ file. (For details see ‘Writing R Extensions’ §4.5.)

R CMD build now omits tarballs and binaries of previous builds from the top-level package directory; PR#17828 , patch by Sebastian Meyer.

R CMD check can now scan package functions for bogus return statements, which were possibly intended as return() calls (wish of PR#17180 , patch by Sebastian Meyer). This check can be activated via the new environment variable _R_CHECK_BOGUS_RETURN_, true for --as-cran .

The LINPACK argument to chol.default() , chol2inv() , solve.default() and svd() has been defunct since R 3.1.0. It was silently ignored up to R 4.0.3 but now gives an error.

R CMD config CXXCPP is defunct (it was deprecated in R 3.6.2).

Defunct functions checkNEWS() and readNEWS() from package tools and CRAN.packages() from utils have been removed.

Function plclust() from the package stats and package.dependencies() , pkgDepends() , getDepList() , installFoundDepends() , and vignetteDepends() from package tools are defunct.

all.equal(x,y) now “sees” the two different NA s in factors, thanks to Bill Dunlap and others in PR#17897 .

all.equal.POSIXt() no longer warns about and subsequently ignores inconsistent "tzone" attributes, but describes the difference in its return value ( PR#17277 ). This check can be disabled via the new argument check.tzone = FALSE ; as suggested by Sebastian Meyer.

A very old bug could cause a segfault in model.matrix() when terms involved logical variables. Related to PR#17879 , but not a complete fix for that issue.

The horizontal position of leaves in a dendrogram is now correct also with center = FALSE ; PR#14938 , patch from Sebastian Meyer.

update.default() now calls the generic update() on the formula to work correctly for models with extended formulas; as reported and suggested by Neal Fultz in PR#17865 .

The R CMD check <pkg> gives a longer and more comprehensible message when ‘DESCRIPTION’ misses dependencies, e.g., in Imports: ; thanks to the contributors of PR#17179 .

The help page for xtabs() now correctly states that addNA is setting na.action = na.pass among others; reported as PR#17770 by Thomas Soeiro.

phyper(11, 15, 0, 12, log.p=TRUE) no longer gives NaN ; reported as PR#17271 by Alexey Stukalov.

boxplot() now also accepts call s for labels such as ylab , the same as plot() . Reported by Marius Hofert.

round() and signif() no longer tolerate wrong argument names, notably in 1-argument calls; reported by Shane Mueller on the R-devel mailing list.

R CMD check etc now warn when a package exports non-existing S4 classes or methods, also in case of no "methods" presence; reported by Alex Bertram; repr.ex. and patch by Sebastian Meyer in PR#16662 .

Bug fix for replayPlot() ; this was turning off graphics engine display list recording if a recorded plot was replayed in the same session. The impact of the bug became visible if resize the device after replay OR if attempted another savePlot() after replay (empty display list means empty screen on resize or empty saved plot).

Many more C-level allocations (mainly by malloc and strdup ) are checked for success with suitable alternative actions.

When install.packages(type = "source") fails to find a package in a repository it mentions package versions which are excluded by their R version requirement and links to hints on why a package might not be found.

On macOS, "macOS" is used by default if the system timezone database is a newer version than that in the R installation.

On platforms using configure option --with-internal-tzcode, additional values "internal" and (on macOS only) "macOS" are accepted for the environment variable TZDIR. (See ?TZDIR .)

There is a new LTO_LD macro to set linker options for LTO compilation, for example to select an alternative linker or to parallelize thin LTO.

There is support for setting a different LTO flag for the Fortran compiler, including to empty when mixing clang and gfortran (as on macOS). See file ‘config.site’.

There is now support for parallelized Link-Time Optimization (LTO) with GCC and for ‘thin’ LTO with clang via setting the LTO macro.

The LINPACK argument to chol.default() , chol2inv() , solve.default() and svd() has been defunct since R 3.1.0. Using it now gives a warning which will become an error in R 4.1.0.

tar() no longer skips non-directory files, thanks to a patch by Sebastian Meyer, fixing the remaining part of PR#16716 .

duplicated() now works also for strings with multiple encodings inside a single vector PR#17809 .

Accessing a long vector represented by a compact integer sequence no longer segfaults (reported and debugged by Hugh Parsonage).

fisher.test() no longer segfaults when called again after its internal stack has been exceeded PR#17904 .

R_allocLD() has been fixed to return memory aligned for long double type PR#16534 .

isS3stdGeneric(f) now detects an S3 generic also when it it is trace() d, thanks to Gabe Becker's PR#17917 .

as.Date(<char>) now also works with an initial "" , thanks to Michael Chirico's PR#17909 .

Further, quantile(x, prN, names=FALSE) now works even when prN contains NA s, thanks to Anggono's PR#17892 . Ditto for ordered factors or Date objects when type = 1 or 3 , thanks to PR#17899 .

quantile(x, pr) works more consistently for pr values slightly outside [0,1], thanks to Suharto Anggono's PR#17891 .

Low-level socket read/write operations have been fixed to correctly signal communication errors. Previously, such errors could lead to a segfault due to invalid memory access. Reported and debugged by Dmitriy Selivanov in PR#17850 .

chisq.test(*, simulate.p.value=TRUE) and r2dtable() now work correctly for large table entries (in the millions). Reported by Sebastian Meyer and investigated by more helpers in PR#16184 .

rank(x) and hence sort(x) now work when x is an object (as per is.object(x) ) of type "raw" and provides a valid `[` method, e.g., for gmp::as.bigz(.) numbers.

addmargins(*, ..) now also works when fn() is a local function, thanks to bug report and patch PR#17124 from Alex Bertram.

Fix to correctly show the group labels in dotchart() (which where lost in the ylab improvement for R 4.0.0).

The code mitigating stack overflow with PCRE regexps on very long strings is enabled for PCRE2 < 10.30 also when JIT is enabled, since stack overflows have been seen in that case.

R CMD check skips vignette re-building (with a warning) if the VignetteBuilder package(s) are not available.

regexpr(*, perl=TRUE) no longer returns incorrect positions into text containing characters outside of the Unicode Basic Multilingual Plane on Windows.

on.exit() now correctly matches named arguments, thanks to PR#17815 (including patch) by Brodie Gaslam.

source(*, echo=TRUE) no longer fails in some cases with empty lines; reported by Bill Dunlap in PR#17769 .

The summary(<warnings>) method now maps the counts correctly to the warning messages.

A package whose code uses this should depend on R (>= 4.0.1).

paste() and paste0() gain a new optional argument recycle0 . When set to true, zero-length arguments are recycled leading to character(0) after the sep -concatenation, i.e., to the empty string "" if collapse is a string and to the zero-length value character(0) when collapse = NULL .

Parse data for raw strings is now recorded correctly. Reported by Gabor Csardi.

parallel::detect.cores(all.tests = TRUE) tries a matching OS name before the other tests (which were intended only for unknown OSes).

plot(y ~ x, ylab = quote(y[i])) now works, as e.g., for xlab ; related to PR#10525 .

In R 4.0.0, sort.list(x) when is.object(x) was true, e.g., for x <- I(letters) , was accidentally using method = "radix" . Consequently, e.g., merge(<data.frame>) was much slower than previously; reported in PR#17794 .

Computing the base value, i.e., 2, “everywhere”, now uses FLT_RADIX , as the original ‘machar’ code looped indefinitely on the ppc64 architecture for the longdouble case.

Fix for adding two complex grid units via sum() . Thanks to Gu Zuguang for the report and Thomas Lin Pedersen for the patch.

Fix a dozen places (code, examples) as Sys.setlocale() returns the new rather than the previous setting.

aov(frml, ...) now also works where the formula deparses to more than 500 characters, thanks to a report and patch proposal by Jan Hauffa.

Packages which define S4 generics for plot() should be re-installed and package code using such generics from other packages needs to ensure that they are imported rather than rely on their being looked for on the search path (as in a namespace, the base namespace has precedence over the search path).

The plot() S3 generic function is now in package base rather than package graphics, as it is reasonable to have methods that do not use the graphics package. The generic is currently re-exported from the graphics namespace to allow packages importing it from there to continue working, but this may change in future.

A large number of packages relied on the previous behaviour and so have needed/will need updating.

R now uses a stringsAsFactors = FALSE default, and hence by default no longer converts strings to factors in calls to data.frame() and read.table() .

There is a new syntax for specifying raw character constants similar to the one used in C++: r"(...)" with ... any character sequence not containing the sequence )". This makes it easier to write strings that contain backslashes or both single and double quotes. For more details see ?Quotes .

S3 methods for class "array" are now dispatched for matrix objects.

matrix objects now also inherit from class "array" , so e.g., class(diag(1)) is c("matrix", "array") . This invalidates code incorrectly assuming that class(matrix_obj)) has length one.

Packages need to be (re-)installed under this version (4.0.0) of R .

This change is expected to have almost no impact on packages using supported coding practices in their C/C++ code.

Reference counting is now used instead of the NAMED mechanism for determining when objects can be safely mutated in base C code. This reduces the need for copying in some cases and should allow further optimizations in the future. It should help make the internal code easier to maintain.

Option PCRE_study is no longer used with PCRE2, and is reported as FALSE when that is in use.

PCRE2 reports errors for some regular expressions that were accepted by PCRE1. A hyphen now has to be escaped in a character class to be interpreted as a literal (unless first or last in the class definition). \R, \B and \X are no longer allowed in character classes (PCRE1 treated these as literals).

Making PCRE2 available when building R from source is strongly recommended (preferably version 10.30 or later) as PCRE1 is no longer developed: version 8.44 is ‘likely to be the final release’.

This version of R is built against the PCRE2 library for Perl-like regular expressions, if available. (On non-Windows platforms PCRE1 can optionally be used if PCRE2 is not available at build time.) The version of PCRE in use can be obtained via extSoftVersion() : PCRE1 (formerly known as ‘PCRE’) has versions <= 8, PCRE2 versions >= 10.

assertError() and assertWarning() (in package tools) can now check for specific error or warning classes via the new optional second argument classes (which is not back compatible with previous use of an unnamed second argument).

DF2formula() , the utility for the data frame method of formula() , now works without parsing and explicit evaluation, starting from Suharto Anggono's suggestion in PR#17555.

approxfun() and approx() gain a new argument na.rm defaulting to true. If set to false, missing y values now propagate into the interpolated values.

Long vectors are now supported as the seq argument of a for() loop.

str(x) gets a new deparse.lines option with a default to speed it up when x is a large call object.

The internal traceback object produced when an error is signalled ( .Traceback ), now contains the call s rather than the deparse() d calls, deferring the deparsing to the user-level functions .traceback() and traceback() . This fulfils the wish of PR#17580, reported including two patch proposals by Brodie Gaslam.

data.matrix() now converts character columns to factors and from this to integers.

package.skeleton() now explicitly lists all exports in the ‘NAMESPACE’ file.

New function .S3method() to register S3 methods in R scripts.

file.path() has some support for file paths not in the session encoding, e.g. with UTF-8 inputs in a non-UTF-8 locale the output is marked as UTF-8.

Most functions with file-path inputs will give an explicit error if a file-path input in a marked encoding cannot be translated (to the native encoding or in some cases on Windows to UTF-8), rather than translate to a different file path using escapes. Some (such as dir.exists() , file.exists() , file.access() , file.info() , list.files() , normalizePath() and path.expand() ) treat this like any other non-existent file, often with a warning.

There is a new help document accessed by help("file path encoding") detailing how file paths with marked encodings are handled.

New function list2DF() for creating data frames from lists of variables.

iconv() has a new option sub = "Unicode" to translate UTF-8 input invalid in the to encoding using <U+xxxx> escapes.

There is a new function infoRDS() providing information about the serialization format of a serialized object.

S3 method lookup now by default skips the elements of the search path between the global and base environments.

Added an argument add_datalist(*, small.size = 0) to allow the creation of a ‘data/datalist’ file even when the total size of the data sets is small.

The backquote function bquote() has a new argument splice to enable splicing a computed list of values into an expression, like ,@ in LISP's backquote.

The formula interface to t.test() and wilcox.test() has been extended to handle one-sample and paired tests.

The palette() function has a new default set of colours (which are less saturated and have better accessibility properties). There are also some new built-in palettes, which are listed by the new palette.pals() function. These include the old default palette under the name "R3" . Finally, the new palette.colors() function allows a subset of colours to be selected from any of the built-in palettes.

n2mfrow() gains an option asp = 1 to specify the aspect ratio, fulfilling the wish and extending the proposal of Michael Chirico in PR#17648.

For head(x, n) and tail() the default and other S3 methods notably for vector n , e.g. to get a “corner” of a matrix, has been extended to array 's of higher dimension thanks to the patch proposal by Gabe Becker in PR#17652. Consequently, optional argument addrownums is deprecated and replaced by the (more general) argument keepnums . An invalid second argument n now leads to typically more easily readable error messages.

New function .class2() provides the full character vector of class names used for S3 method dispatch.

Printing methods(..) now uses a new format() method.

sort.list(x) now works for non-atomic objects x and method = "auto" (the default) or "radix" in cases order(x) works, typically via a xtfrm() method.

Where they are available, writeBin() allows long vectors.

New function deparse1() produces one string, wrapping deparse() , to be used typically in deparse1(substitute(*)) , e.g., to fix PR#17671.

wilcox.test() enhancements: In the (non-paired) two-sample case, Inf values are treated as very large for robustness consistency. If exact computations are used, the result now has "exact" in the method element of its return value. New arguments tol.root and digits.rank where the latter may be used for stability to treat very close numbers as ties.

readBin() and writeBin() now report an error for an invalid endian value. The affected code needs to be fixed with care as the old undocumented behavior was to swap endian-ness in such cases.

sequence() is now an S3 generic with an internally implemented default method, and gains arguments to generate more complex sequences. Based on code from the S4Vectors Bioconductor package and the advice of Hervé Pagès.

print() 's default method and many other methods (by calling the default eventually and passing ... ) now make use of a new optional width argument, avoiding the need for the user to set and reset options("width") .

memDecompress() supports the RFC 1952 format (e.g. in-memory copies of gzip -compressed files) as well as RFC 1950.

memCompress() and memDecompress() support long raw vectors for types "gzip" and "zx" .

sweep() and slice.index() can now use names of dimnames for their MARGIN argument ( apply has had this for almost a decade).

New function proportions() and marginSums() . These should replace the unfortunately named prop.table() and margin.table() . They are drop-in replacements, but also add named-margin functionality. The old function names are retained as aliases for back-compatibility.

Functions rbinom() , rgeom() , rhyper() , rpois() , rnbinom(), rsignrank() and rwilcox() which have returned integer since R 3.0.0 and hence NA when the numbers would have been outside the integer range, now return double vectors (without NAs, typically) in these cases.

matplot(x,y) (and hence matlines() and matpoints() ) now call the corresponding methods of plot() and lines() , e.g, when x is a "Date" or "POSIXct" object; prompted by Spencer Graves' suggestion.

stopifnot() now allows customizing error messages via argument names, thanks to a patch proposal by Neal Fultz in PR#17688.

unlink() gains a new argument expand to disable wildcard and tilde expansion. Elements of x of value "~" are now ignored.

mle() in the stats4 package has had its interface extended so that arguments to the negative log-likelihood function can be one or more vectors, with similar conventions applying to bounds, start values, and parameter values to be kept fixed. This required a minor extension to class "mle" , so saved objects from earlier versions may need to be recomputed.

The default for pdf() is now useDingbats = FALSE .

The default fill colour for hist() and boxplot() is now col = "lightgray" .

The default order of the levels on the y-axis for spineplot() and cdplot() has been reversed.

If the R_ALWAYS_INSTALL_TESTS environment variable is set to a true value, R CMD INSTALL behaves as if the --install-tests option is always specified. Thanks to Reinhold Koch for the suggestion.

New function R_user_dir() in package tools suggests paths appropriate for storing R-related user-specific data, configuration and cache files.

capabilities() gains a new logical option Xchk to avoid warnings about X11-related capabilities.

The internal implementation of grid units has changed, but the only visible effects at user-level should be a slightly different print format for some units (especially unit arithmetic),

faster performance (for unit operations) and

two new functions unitType() and unit.psum() . Based on code contributed by Thomas Lin Pedersen.

When internal dispatch for rep.int() and rep_len() fails, there is an attempt to dispatch on the equivalent call to rep() .

Object .Machine now contains new longdouble.* entries (when R uses long doubles internally).

news() has been enhanced to cover the news on R 3.x and 2.x.

For consistency, N <- NULL; N[[1]] <- val now turns N into a list also when val) has length one. This enables dimnames(r1)[[1]] <- "R1" for a 1-row matrix r1 , fixing PR#17719 reported by Serguei Sokol.

deparse(..) , dump(..) , and dput(x, control = "all") now include control option "digits17" which typically ensures 1:1 invertibility. New option control = "exact" ensures numeric exact invertibility via "hexDigits" .

When loading data sets via read.table() , data() now uses LC_COLLATE=C to ensure locale-independent results for possible string-to-factor conversions.

A server socket connection, a new connection type representing a listening server socket, is created via serverSocket() and can accept multiple socket connections via socketAccept() .

New function socketTimeout() changes the connection timeout of a socket connection.

The time needed to start a homogeneous PSOCK cluster on localhost with many nodes has been significantly reduced (package parallel).

New globalCallingHandlers() function to establish global condition handlers. This allows registering default handlers for specific condition classes. Developed in collaboration with Lionel Henry.

New function tryInvokeRestart() to invoke a specified restart if one is available and return without signaling an error if no such restart is found. Contributed by Lionel Henry in PR#17598.

str(x) now shows the length of attributes in some cases for a data frame x .

Rprof() gains a new argument filter.callframes to request that intervening call frames due to lazy evaluation or explicit eval() calls be omitted from the recorded profile data. Contributed by Lionel Henry in PR#17595.

The handling of ${FOO-bar} and ${FOO:-bar} in ‘Renviron’ files now follows POSIX shells (at least on a Unix-alike), so the first treats empty environment variables as set and the second does not. Previously both ignored empty variables. There are several uses of the first form in ‘etc/Renviron’.

New classes argument for suppressWarnings() and suppressMessages() to selectively suppress only warnings or messages that inherit from particular classes. Based on patch from Lionel Henry submitted with PR#17619.

New function activeBindingFunction() retrieves the function of an active binding.

New "cairoFT" and "pango" components in the output of grSoftVersion() .