rv init
rv init will initialize a new or existing project by:
- Setting up the project infrastructure, including the project library and activation scripts.
- Creating a configuration file which is populated with the R version and repositories
rv init [project_directory] [OPTIONS]Arguments
Section titled “Arguments”-
project_directoryoptional - Creates anrvproject at the directory specifiedDefault: current directory (
./)
Options
Section titled “Options”-
--r-version- The R version is set to be the version found on the path by default. Use this flag to set a custom version. -
--no-repositories- The repositories are set to what is found in the current R profile, inoption("repos"), by default. This flag leaves the repositories field in the config file blank. -
--add- The dependency field is blank by default. This flag can be used to add dependencies you know will be needed to the project immediately. It does not sync these dependencies likerv add. This flag is repeatable (--add pkg1 --add pkg2) to add multiple dependencies, rather than taking a single space-separated list.
-
--no-r-environment- By default,rvcreates an R environment.rvto enablervto be called in R code (see rvr for more info). This flag will disable this R environment. -
--force- By default, if anrproject.tomlexists within a directory already,rvwill not overwrite the file. The flag will force the creation of a new config file.
Example
Section titled “Example”Follow the tabs below to see the changes:
rv init my_rv_project --r-version 4.5 --add tidyverseDirectorymy_rv_project
Directoryrv/
Directorylibrary/
- …
Directoryscripts/
- activate.R set the library and repositories within R
- rvr.R set up
.rv. See rvr for more info
- .gitignore ignores the library
- .Rprofile
- rproject.toml
[project]name = "my_rv_project"r_version = "4.5"
# Optional: base URL for `rv add owner/repo` shorthand (defaults to https://github.com).# git_shorthand_base_url = "https://github.example.com"# A list of repositories to fetch packages from. Order matters: we will try to get a package from each repository in order.# The alias is only used in this file if you want to specifically require a dependency to come from a certain repository.# Example: { alias = "PPM", url = "https://packagemanager.posit.co/cran/latest" },repositories = [ {alias = "CRAN", url = "https://cran.rstudio.com"},]
# A list of packages to install and any additional configuration# Examples: # "dplyr", # {name = "dplyr", repository = "CRAN"}, # {name = "dplyr", git = "https://github.com/tidyverse/dplyr.git", tag = "v1.1.4"},dependencies = [ "tidyverse",]