R Observatory
Search
install.packages("withr")
CRAN 30-day downloads, method
1.7M−6.2% down on the 30 days before, the worse direction
Dependent packages, method
4021,260 more suggest it
Test coverage, method
86%of lines run by tests

A set of functions to run code 'with' safely and temporarily modified global state. Many of these functions were originally a part of the 'devtools' package, this provides a simple package with limited dependencies to provide access to these functions.

Maintainer
Lionel Henry
Latest release
19 Jun 2026
First release
23 Sep 2015

Compare with another package

More details
Releases
20
Needs compilation
No
Needs R
>= 3.6.0
Config/Needs/website
tidyverse/tidytemplate
Config/testthat/edition
3
RoxygenNote
7.3.2
Task views (1)
Cite

Package

Run in R for the authors' preferred citation:

citation("withr")
APA
Henry, L., Posit Software, PBC, Bryan, J., Chang, W., Cotton, R., Hester, J., Müller, K., Ushey, K., & Wickham, H. (2026). withr: Run Code 'With' Temporarily Modified Global State (Version 3.0.3) [Computer software]. https://doi.org/10.32614/CRAN.package.withr
About

This package has no citation file, so citation() returns this entry built from DESCRIPTION.

R Observatory

For a number measured here: a download total, a coverage figure, an archival date.

APA
Balamuta, J. J. (2026). R Observatory: Metrics for withr version 3.0.3 [Data set]. HJJB, LLC. Data release v2026-10-29. https://doi.org/10.5281/zenodo.21843040
About

From data release v2026-10-29, which the citation names so these numbers can be found later.

All 13 check platforms pass.

  • r-devel-linux-x86_64-debian-clang

    The unreleased R on Linux, x86_64, debian-clang

    OK

    Version checked
    3.0.3
    Time taken
    54 s
  • r-devel-linux-x86_64-debian-gcc

    The unreleased R on Linux, x86_64, debian-gcc

    OK

    Version checked
    3.0.3
    Time taken
    42 s
  • r-devel-linux-x86_64-fedora-clang

    The unreleased R on Linux, x86_64, fedora-clang

    OK

    Version checked
    3.0.3
    Time taken
    36 s
  • r-devel-linux-x86_64-fedora-gcc

    The unreleased R on Linux, x86_64, fedora-gcc

    OK

    Version checked
    3.0.3
    Time taken
    41 s
  • r-devel-windows-x86_64

    The unreleased R on Windows, x86_64

    OK

    Version checked
    3.0.3
    Time taken
    116 s
  • r-oldrel-macos-arm64

    The previous release of R on macOS, arm64

    OK

    Version checked
    3.0.3
    Time taken
    68 s
  • r-oldrel-macos-x86_64

    The previous release of R on macOS, x86_64

    OK

    Version checked
    3.0.3
    Time taken
    172 s
  • r-oldrel-windows-x86_64

    The previous release of R on Windows, x86_64

    OK

    Version checked
    3.0.3
    Time taken
    102 s
  • r-patched-linux-x86_64

    The patched release of R on Linux, x86_64

    OK

    Version checked
    3.0.3
    Time taken
    48 s
  • r-release-linux-x86_64

    The current release of R on Linux, x86_64

    OK

    Version checked
    3.0.3
    Time taken
    46 s
  • r-release-macos-arm64

    The current release of R on macOS, arm64

    OK

    Version checked
    3.0.3
    Time taken
    59 s
  • r-release-macos-x86_64

    The current release of R on macOS, x86_64

    OK

    Version checked
    3.0.3
    Time taken
    170 s
  • r-release-windows-x86_64

    The current release of R on Windows, x86_64

    OK

    Version checked
    3.0.3
    Time taken
    88 s
  • 13 OK

Over time

No change since 4 Aug 2026

As a list (4)
ChangedWorst statusOKNotesWarningsErrors
4 Aug 2026OK13000
1 Aug 2026Note12100
22 Jun 2026OK13000
10 Mar 2026Error13001

Since March 2026

Check results on CRAN

Total downloads in the last 30 days
2,117,286+0.47% up on the 30 days before, the better directionIt is the sum of 4 channels: CRAN, r2u, conda-forge and c2d4u. autoCRAN is switched off.

CRAN rank

10 of 26,553

CRAN

1,678,637 downloads in the last 30 days

Rank
10 of 26,553
Change
−6.2% down on the 30 days before, the worse direction

It is in the total. Take it out

r2u

65,667 downloads in the last 30 days

Rank
5 of 30,526
Change
+97.8% up on the 30 days before, the better direction

It is in the total. Take it out

autoCRAN

177 downloads in the last 30 days

Rank
322 of 29,233
Change
+20.4% up on the 30 days before, the better direction

It is switched off. Put it back

conda-forge

371,496 downloads in the last 30 days

Rank
7 of 3,828
Change
+31.4% up on the 30 days before, the better direction

It is in the total. Take it out

c2d4u, no longer updated

1,486 downloads in the last 30 days

Rank
7 of 7,575
Change
−11.3% down on the 30 days before, the worse direction

It is in the total. Take it out

Over time

Compare downloads

Needs
2
Dependent packages
402
Suggested by
1,260
Needs (2)
  • graphics
  • grDevices
Installing it adds
0 packages, 0 KB of source
Of those, need compilation
0
Optional extras (8)
Dependent packages (50 of 402)
PackageTitleDownloads in 30 days
ggplot2Create Elegant Data Visualisations Using the Grammar of Graphics2,048,054
tidyselectSelect from a Set of Strings1,080,980
shinyWeb Application Framework for R809,005
readrRead Rectangular Text Data748,961
testthatUnit Testing for R703,527
vroomRead and Write Rectangular Text Data Quickly651,646
gargleUtilities for Working with Google APIs433,152
googledriveAn Interface to Google Drive427,205
googlesheets4Access Google Sheets using the Sheets API V4423,558
dbplyrA 'dplyr' Back End for Databases418,441
reprexPrepare Reproducible Example Code via the Clipboard406,396
forecastForecasting Functions for Time Series and Linear Models395,190
ggrepelAutomatically Position Non-Overlapping Text Labels with 'ggplot2'392,310
httr2Perform HTTP Requests and Process the Responses365,017
devtoolsTools to Make Developing R Packages Easier301,743
ggridgesRidgeline Plots in 'ggplot2'282,041
roxygen2In-Line Documentation for R278,149
ggdistVisualizations of Distributions and Uncertainty224,766
usethisAutomate Package and Project Setup219,494
rexFriendly Regular Expressions214,771
pkgdownMake Static HTML Documentation for a Package201,920
reticulateInterface to 'Python'172,982
covrTest Coverage for Packages159,854
rcmdcheckRun 'R CMD check' from 'R' and Capture Results127,871
recipesPreprocessing and Feature Engineering Steps for Modeling126,902
downlitSyntax Highlighting and Automatic Linking125,188
caretClassification and Regression Training118,208
ggforceAccelerating 'ggplot2'92,750
DescToolsTools for Descriptive Statistics64,067
ggraphAn Implementation of Grammar of Graphics for Graphs and Networks62,758
stylerNon-Invasive Pretty Printing of R Code52,971
chromoteHeadless Chrome Web Browser Interface47,823
RPostgresC++ Interface to PostgreSQL47,600
torchTensors and Neural Networks with 'GPU' Acceleration43,580
yardstickTidy Characterizations of Model Performance30,778
cyclocompCyclomatic Complexity of R Code29,975
workflowsModeling Workflows28,605
inferTidy Statistical Inference25,877
dialsTools for Creating Tuning Parameter Values25,757
tuneTidy Tuning Tools24,212
sparklyrR Interface to Apache Spark23,733
learnrInteractive Tutorials for R22,128
workflowsetsCreate a Collection of 'tidymodels' Workflows20,039
shinytest2Testing for Shiny Applications18,297
mockrMocking in R16,959
FSASimple Fisheries Stock Assessment Methods16,181
themisExtra Recipes Steps for Dealing with Unbalanced Data11,485
readODSRead and Write ODS Files10,553
fmesherTriangle Meshes and Related Geometry Tools9,858
statsExpressionsTidy Dataframes and Expressions with Statistical Details8,329
Functions
119
Public exports
79
Lines of R code
2,548
Median complexity
1
Functions (119)
Size and composition

Lines by kind (6,575)

KindLinesShare
R code2,54839%
Tests2,07632%
Documentation1,60824%
Guides3435%

Lines by language

LanguageLinesShare
R4,52069%
Rd1,60825%
Vignettes3435%
Markdown1042%

Languages are counted from file extensions.

Files
110
R functions
119
Deprecated functions
2
Complexity
Median
1
Mean
2.09
Highest
13
Median lines per function
7
About complexity

Cyclomatic complexity counts the independent paths through a function: 1 is a straight line, higher is harder to test. R functions only.

Call graph figures
R functions
119
Calls
129
Unconnected
14
Groups
3
Growth (20 releases)
Total lines by release
1,037 on 23 Sep 20156,575 on 19 Jun 2026
Release changes

The tests ran and coverage was measured.

Lines run by tests
85.7%
Expressions run by tests
85.7%
Test cases
140
Exports named in tests
88.6%
Coverage by file (27)
Coverage run
Lines counted
750
Lines the tests ran
643
Tests passed
Yes
Measured with
covr 3.6.5 on R 4.6.1
Test suite
Has tests
Yes
Test frameworks
testthat, tinytest
Test cases
140
Snapshot tests
10
Lines of tests
2,076
Test lines per line of code
0.81
Exports documented
100%
Arguments documented
85.1%
Return value documented
80.8%
Help pages with examples
75%
Examples run in checks
95.2%
Guides (1)
Other documentation
README
Yes, 597 words
Release notes file
Yes
Help pages
28
Lines of documentation
1,608

Funded by Posit Software, PBC

Earlier names (1)
  • RStudio

r-lib / withr on github.com

Stars
181+0.56% up on 30 days ago, the better direction
Forks
47
Open issues
28
Last commit
12 Oct 2026
Activity
Commits
610
Open pull requests
4
Tagged releases
17
Latest tagged release
v3.0.3, 22 Jun 2026
In development
Default branch at 3.0.3.9000, ahead of CRAN 3.0.3 (checked 2026-10-25)
Issues closed in
84 days (median)
Pull requests closed in
1 day (median)
Pull requests merged
90%
Created
21 Apr 2015
Licence file reads as
–
Development practices (12)
KindFound
Continuous integrationGitHub Actions, R CMD check workflow
The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel
Docs sourceREADME.Rmd, pkgdown
GitHub Pages site last deployed 2026-10-12
The repository has a site deploy workflow
pkgdown site last built 2026-06-22
CoverageCoverage reporting (Codecov), .covrignore
CRAN release processcran-comments.md, revdep/
Lint, format, editorlintr, RStudio project

Method, repository practices

Across r-lib

R releases
  • On CRAN
  • Release
VersionReleasedREvents
3.0.3 current19 Jun 20264.6.0
3.0.228 Oct 20244.4.1
3.0.131 Jul 20244.4.1
3.0.016 Jan 20244.3.2
2.5.230 Oct 20234.3.1
2.5.126 Sep 20234.3.1
2.5.03 Mar 20224.1.2
2.4.330 Nov 20214.1.2Maintainer: Lionel Henry
Earlier versions (12)
VersionReleasedREvents
2.4.218 Apr 20214.0.5
2.4.126 Jan 20214.0.3
2.4.016 Jan 20214.0.3Licence: MIT + file LICENSE
2.3.022 Sep 20204.0.2
2.2.021 Apr 20203.6.3
2.1.215 Mar 20183.4.4
2.1.119 Dec 20173.4.3
2.1.01 Nov 20173.4.2
2.0.029 Jul 20173.4.1
1.0.220 Jun 20163.3.0
1.0.14 Feb 20163.2.3
1.0.023 Sep 20153.2.2

Relicensed from GPL (>= 2) in version 2.4.0.

Release notes (3.0.3)
  • Fixes for CRAN checks.
  • Fixed issue that prevented local_seed() from preserving the seed (#286, @BjarkeHautop). Note: If you had before: ``r test_that("A", { withr::local_seed(1) # Seeds locally runif(...) }) test_that("B", { runif(...) # NO seed of its own }) `` Before the fix, the test "B" was accidentally seeded by "A". Now it needs to be seeded on its own.