Description Usage Arguments Value Examples
These functions are inspired by usethis::use_r()
to create .R files in the
R/ directory for packages. Unlike use_r()
, these functions allow you to
pass in any path within your RStudio Project. It will then create and
(optionally) open the file within RStudio.
There is both a generic file_new()
function, which accepts paths and the
file extension, as well as several utility functions that simply require a
path. See usage or examples for more details.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | file_new(path, ext, open = interactive())
file_new_r(path, open = interactive())
file_new_stan(path, open = interactive())
file_new_js(path, open = interactive())
file_new_css(path, open = interactive())
file_new_html(path, open = interactive())
file_new_text(path, open = interactive())
file_new_md(path, open = interactive())
file_new_rmd(path, open = interactive())
|
path |
A character vector of the file path to be created. |
ext |
The file extension, e.g. "R" or "Rmd" for .R and .Rmd files, respectively. |
open |
Logical: whether to open the file for editing. Default calls
|
NA; used to create and (optionally) open a new file of the specified type.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | if (interactive()) {
# Create a new R file, specifying the extension
file_new(path = "test-folder/test-file", ext = "R")
# Create a new R file with the shortcut:
file_new_r(path = "test-folder/test-file")
# Create a new Stan file
file_new(path = "test-folder/test-file", ext = "stan")
# Alternatively:
# file_new_stan(path = "test-folder/test-file")
# Create a new JavaScript file
file_new(path = "test-folder/test-file", ext = "js")
# Alternatively:
# file_new_js(path = "test-folder/test-file")
# Create a new CSS file
file_new(path = "test-folder/test-file", ext = "css")
# Alternatively:
# file_new_css(path = "test-folder/test-file")
# Create a new HTML file
file_new(path = "test-folder/test-file", ext = "html")
# Alternatively:
# file_new_html(path = "test-folder/test-file")
# Create a new Text file
file_new(path = "test-folder/test-file", ext = "txt")
# Alternatively:
# file_new_text(path = "test-folder/test-file")
# Create a new Markdown file
file_new(path = "test-folder/test-file", ext = "md")
# Alternatively:
# file_new_md(path = "test-folder/test-file")
# Create a new RMarkdown file
file_new(path = "test-folder/test-file", ext = "Rmd")
# Alternatively:
# file_new_rmd(path = "test-folder/test-file")
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.