Skip to main content
AI in Production 2026 is now open for talk proposals.
Share insights that help teams build, scale, and maintain stronger AI systems.
items
Menu
  • About
    • Overview 
    • Join Us  
    • Community 
    • Contact 
  • Training
    • Overview 
    • Course Catalogue 
    • Public Courses 
  • Posit
    • Overview 
    • License Resale 
    • Managed Services 
    • Health Check 
  • Data Science
    • Overview 
    • Visualisation & Dashboards 
    • Open-source Data Science 
    • Data Science as a Service 
    • Gallery 
  • Engineering
    • Overview 
    • Cloud Solutions 
    • Enterprise Applications 
  • Our Work
    • Blog 
    • Case Studies 
    • R Package Validation 
    • diffify  

New features in R 4.2.0

Author: Colin Gillespie

Published: April 1, 2022

tags: r

R-4.2.0 is due to be released!

Another year has passed, which means an updated version of R is due to be released - R version 4.2.0. As usual there have been many changes and improvements over the last year. This blog post only picks out a tiny handful, but there are dozens of smaller changes and bug fixes that can be found in the changelog.

Do you use Professional Posit Products? If so, check out our managed Posit services

Pipe updates

The native pipe |> was introduced in R 4.1.0. This release has introduced the _ that can be used as a placeholder in a named argument. For example,

# This works in R 4.2
mtcars |>
  lm(mpg ~ disp, data = _)

Side note: some of the older R users amongst us, still remember when _ was used as an assignment operator!

Improved help page

The HTML help system has a few new features:

  • LaTeX-like mathematics can be typeset using either KaTeX or MathJax, usage and example code is highlighted using Prism.
  • Dynamic help for examples and code demos using {knitr}.

The HTML help system now uses HTML5 (via PR#18149). What this means to everyday R users is that the help package looks a lot nicer

The lm help page with R 4.2.0

The examples can now be easily run using the Run Examples button

The Run example page using 4.2.0

if and while statements

Calling while() or if() statements with a condition of length greater than one gives an error rather than a warning.

if (1:2 == 1) do_something()
# Error in if (1:2 == 1) do_something() : the condition has length > 1

This is clearly a good thing, as when the length of the condition is greater than one, this is almost certainly an error. If you are using older versions of R, you can set _R_CHECK_LENGTH_1_CONDITION_ to true in your .Renviron to get the same effect.

Changes to Windows

There are quite few changes to Windows, in particular

  • Support for 32-bit builds has been dropped.
  • UTF-8 locales are used where available.
  • The default personal library on Windows, folder R\win-library\x.y where x.y stands for R release x.y.z, is now a subdirectory of local application data directory (usually a hidden directory C:\Users\username\AppData\Local).

Data frames gain a new method

The as.vector() function gains an S3 data frame method which returns a simple list.

#> as.vector(mtcars[1:5,])
#$mpg
#[1] 21.0 21.0 22.8 21.4 18.7
#
#$cyl
#[1] 6 6 4 6 8
#
#$disp
#[1] 160 160 108 258 360

This is a breaking change; in previous versions of R, as.vector() just returned the data frame.

Changes to logical functions

This was part of R 4.2.0, but has been bumped to R-devel as there are around 200 packages that have to be updated.

Similar to the if() and while() statements, the logical functions, && and ||, now give a warning when one of the comparisons has a length greater than one:

1:2 && 1
# [1] TRUE
# Warning message:
# In 1:2 && 1 : 'length(x) = 2 > 1' in coercion to 'logical(1)'

In future versions, this will become an error.

Trying the latest version out for yourself

The rocker project takes away the pain of installing the latest version. If you have docker installed, then simply use the devel version:

docker run --rm -ti rocker/r-ver:devel

If you want to use RStudio as well, then run

docker run -e PASSWORD=<PASSWORD> -p 8787:8787 rocker/rstudio:devel

See also

Do you have some nostalgia for previous versions of R? If so, check out our previous blog posts:

  • R 4.0.0
  • R 4.1.0

Jumping Rivers Logo

Recent Posts

  • Start 2026 Ahead of the Curve: Boost Your Career with Jumping Rivers Training 
  • Should I Use Figma Design for Dashboard Prototyping? 
  • Announcing AI in Production 2026: A New Conference for AI and ML Practitioners 
  • Elevate Your Skills and Boost Your Career – Free Jumping Rivers Webinar on 20th November! 
  • Get Involved in the Data Science Community at our Free Meetups 
  • Polars and Pandas - Working with the Data-Frame 
  • Highlights from Shiny in Production (2025) 
  • Elevate Your Data Skills with Jumping Rivers Training 
  • Creating a Python Package with Poetry for Beginners Part2 
  • What's new for Python in 2025? 

Top Tags

  • R (236) 
  • Rbloggers (182) 
  • Pybloggers (89) 
  • Python (89) 
  • Shiny (63) 
  • Events (26) 
  • Training (23) 
  • Machine Learning (22) 
  • Conferences (20) 
  • Tidyverse (17) 
  • Statistics (14) 
  • Packages (13) 

Authors

  • Amieroh Abrahams 
  • Colin Gillespie 
  • Aida Gjoka 
  • Gigi Kenneth 
  • Osheen MacOscar 
  • Sebastian Mellor 
  • Keith Newman 
  • Pedro Silva 
  • Shane Halloran 
  • Russ Hyde 
  • Myles Mitchell 
  • Tim Brock 
  • Theo Roe 

Keep Updated

Like data science? R? Python? Stan? Then you’ll love the Jumping Rivers newsletter. The perks of being part of the Jumping Rivers family are:

  • Be the first to know about our latest courses and conferences.
  • Get discounts on the latest courses.
  • Read news on the latest techniques with the Jumping Rivers blog.

We keep your data secure and will never share your details. By subscribing, you agree to our privacy policy.

Follow Us

  • GitHub
  • Bluesky
  • LinkedIn
  • YouTube
  • Eventbrite

Find Us

The Catalyst Newcastle Helix Newcastle, NE4 5TG
Get directions

Contact Us

  • hello@jumpingrivers.com
  • + 44(0) 191 432 4340

Newsletter

Sign up

Events

  • North East Data Scientists Meetup
  • Leeds Data Science Meetup
  • Shiny in Production
British Assessment Bureau, UKAS Certified logo for ISO 9001 - Quality management British Assessment Bureau, UKAS Certified logo for ISO 27001 - Information security management Cyber Essentials Certified Plus badge
  • Privacy Notice
  • |
  • Booking Terms

©2016 - present. Jumping Rivers Ltd