Skip to main content
Super early bird tickets for AI in Production 2027 are on sale now.
See all results
items
    • Overview 
    • Join Us  
    • Community 
    • Contact 
    • Overview 
    • Course Catalogue 
    • Public Courses 
    • Overview 
    • Posit 
    • Data Science 
    • Engineering 
    • Blog 
    • Case Studies 
    • R Package Validation 
    • Gallery 
    • diffify  
    • Pro Bono Support 

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

You might also like

2020 Training Review

Our annual training review is back! Like many other training providers, we had to pivot to online learning in 2020, which brought with it challenges but also new opportunities. The review will show you what the year looked like for our trainers and training course attendees, including which trainer taught the most courses!

Online R and Python Training Courses: 2026 Schedule

A full schedule of online data science training courses is now available through to November 2026, covering R, Python, machine learning, statistical modelling, Shiny, and more. All sessions run online over six hours.

Alt Text in R

Alt text is text that describes the appearance and purpose of an image. This blog post will show you how to include alt text in your web applications and documents when you've built them in R.

Recent Posts

  • Why learn the command-line interface? 
  • A First Look at Positron and Posit Assistant: Free Jumping Rivers Webinar 
  • Five pre-flight checks for your dashboard 
  • AI in Production Conference Summary (2026) 
  • AI in Production 2026 Speakers 
  • Ghost in the Shell Script 
  • Online Data Science Training Courses: R, Python, and Machine Learning in 2026 
  • What's new in R 4.6.0? 
  • Programming with LLMs in R & Python 
  • Using R to Teach R: Lessons for Software Development 

Top Tags

  • R (255) 
  • Rbloggers (199) 
  • Pybloggers (99) 
  • Python (99) 
  • Shiny (65) 
  • Machine Learning (31) 
  • Training (30) 
  • Events (29) 
  • Conferences (21) 
  • Tidyverse (17) 
  • Statistics (16) 
  • Packages (14) 

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
  • AI 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