Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

use_r

Create or edit R or test files


Description

This pair of functions makes it easy to create paired R and test files, using the convention that the tests for R/foofy.R should live in tests/testthat/test-foofy.R. You can use them to create new files from scratch by supplying name, or if you use RStudio, you can call to create (or navigate to) the paired file based on the currently open script.

Usage

use_r(name = NULL, open = rlang::is_interactive())

use_test(name = NULL, open = rlang::is_interactive())

Arguments

name

Either a name without extension, or NULL to create the paired file based on currently open file in the script editor. If the R file is open, use_test() will create/open the corresponding test file; if the test file is open, use_r() will create/open the corresponding R file.

open

Whether to open the file for interactive editing.

See Also

The testing and R code chapters of R Packages.


usethis

Automate Package and Project Setup

v2.0.1
MIT + file LICENSE
Authors
Hadley Wickham [aut] (<https://orcid.org/0000-0003-4757-117X>), Jennifer Bryan [aut, cre] (<https://orcid.org/0000-0002-6983-2759>), RStudio [cph, fnd]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.