Wrapper: new_r + new_test

Usage

new_r_test(fun, r.path = "R", r.file.name = NULL, test.path = "tests/testthat", test.file.name = NULL)

Arguments

fun
A function or character string naming the function.
r.path
Path to directory to generate the function test in. Default is to use "R" for ease of use within RStudio.
r.file.name
By default the file is named the same as fun + ".R". This can be changed by supplying a file name to file.name.
test.path
Path to directory to generate the function test in. Default is to use "tests/testthat" for ease of use within RStudio.
test.file.name
By default the file is named the same as: "text-" + fun + ".R". This can be changed by supplying a file name to file.name.

Wrapper: <code>new_r</code> + <code>new_test</code>

Wrapper: <code>new_r</code> + <code>new_test</code>

Value

Generates ‘____.R’ and ‘test-____.R’ files.

Description

Quickly produce a roxygen2 style.R’ and testthat style test ‘.R’ template files from a function (output file will include the function) or a character string. Wraps new_r and new_test function capabilities into one function call.

Examples

dir.create("temp_dir") new_r_test(paste, r.path = "temp_dir", test.path = "temp_dir")
R file created: temp_dir/paste.R test file created: temp_dir/test-paste.R
new_r_test("myfun", r.path = "temp_dir", test.path = "temp_dir")
R file created: temp_dir/myfun.R test file created: temp_dir/test-myfun.R
unlink("temp_dir", TRUE, TRUE)