You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For the R community, Computo relies on the [**renv**](https://rstudio.github.io/renv/articles/renv.html) package manager to setup a reproducible environment that handles `R` dependencies. Setting up **renv** for use within your repository requires the following steps. First, you need to initialize your repository to work with **renv**. This is done by running:
2
+
3
+
```r
4
+
# Initialize your repo to work with renv
5
+
renv::init()
6
+
```
7
+
8
+
The purpose of this function is to create a `renv.lock` file that registers the version of R and quarto along with all the packages and their versions that **renv** finds in your notebook.
9
+
10
+
Upon cloning one of our template however, the `renv.lock` file already exists. Therefore, when you execute `renv::init()`, you will be provided with the following choices:
prompting you to restart your R session which you should do right away. If you now inspect the existing `renv.lock` file, you will see the R version you locally run on along with a bunch of packages listed there. This is because `template-computo-R.qmd` includes the **ggplot2** package by default to showcase how you can include plots in your paper. As a result, **renv** registers **ggplot2** along with all its dependencies in the `renv.lock` file.
31
+
32
+
Now you can write your contribution, using all the packages you need. Install the required dependencies as usual (via `install.packages()` or via the RStudio IDE) or using **renv** built-in `install()` function:
33
+
34
+
```r
35
+
# Install packages you need
36
+
renv::install("ggplot2") # or equivalently install.packages("ggplot2")
37
+
```
38
+
39
+
Non-CRAN packages (*e.g.* Github packages) can be used. To install such packages, you need to first install the **remotes** package. Then, if you want to install the development version of *e.g.* the **gt** package hosted by `rstudio` GitHub account (useful for nicely and easily formatting tables btw), you would do:
40
+
41
+
```r
42
+
install.packages("remotes")
43
+
remotes::install_github("rstudio/gt")
44
+
```
45
+
46
+
Once you are done, you need to freeze the environment and package versions that are going to be used to run the calculations within your paper. This is achieved via:
The `renv.lock` should be versioned with git. Other files that `renv::snapshot()` might produce should be listed under `.gitignore` and therefore not put under versioning.
55
+
:::
56
+
57
+
More details for using **renv** can be found:
58
+
59
+
- either on the [**renv**](https://rstudio.github.io/renv/articles/renv.html) package website,
60
+
- or on the Quarto website at this [dedicated page](https://quarto.org/docs/projects/virtual-environments.html#using-renv).
Copy file name to clipboardExpand all lines: site/guidelines-authors.qmd
+4-63Lines changed: 4 additions & 63 deletions
Original file line number
Diff line number
Diff line change
@@ -134,83 +134,24 @@ You can customize most of the entries in that file except `project:`, `published
134
134
135
135
### Setup dependencies
136
136
137
-
The next step is to inform Computo of the other packages or tools that your paper might depend upon. It is important to freeze their versions to ensure reproducibility. This step is inherently handled differently whether you are an R, Python or Julia user.
137
+
The next step is to inform Computo of the other packages, tools and environment that your paper might depend upon. It is important to freeze their versions to ensure reproducibility. This step is inherently handled differently whether you are an R, Python or Julia user.
138
138
139
139
::: {.callout-note icon="false" collapse="true"}
140
140
#### R users
141
141
142
-
For the R community, Computo relies on the [**renv**](https://rstudio.github.io/renv/articles/renv.html) package manager to setup a reproducible environment that handles `R` dependencies. Setting up **renv** for use within your repository requires the following steps. First, you need to initialize your repository to work with **renv**. This is done by running:
143
-
144
-
```r
145
-
# Initialize your repo to work with renv
146
-
renv::init()
147
-
```
148
-
149
-
The purpose of this function is to create a `renv.lock` file that registers the version of R and quarto along with all the packages and their versions that **renv** finds in your notebook.
150
-
151
-
Upon cloning one of our template however, the `renv.lock` file already exists. Therefore, when you execute `renv::init()`, you will be provided with the following choices:
152
-
153
-
```r
154
-
> renv::init()
155
-
This project already has a lockfile. What would you like to do?
156
-
157
-
1: Restore the project from the lockfile.
158
-
2: Discard the lockfile and re-initialize the project.
159
-
3: Activate the project without snapshotting or installing any packages.
160
-
4: Abort project initialization.
161
-
```
162
-
163
-
You should choose **Option 2**, which will extend the message box with:
164
-
165
-
```r
166
-
- Linking packages into the project library ... Done!
167
-
- Lockfile written to "~/Projects/computo/my-computo-submission/renv.lock".
168
-
- renv activated -- please restart the R session.
169
-
```
170
-
171
-
prompting you to restart your R session which you should do right away. If you now inspect the existing `renv.lock` file, you will see the R version you locally run on along with a bunch of packages listed there. This is because `template-computo-R.qmd` includes the **ggplot2** package by default to showcase how you can include plots in your paper. As a result, **renv** registers **ggplot2** along with all its dependencies in the `renv.lock` file.
172
-
173
-
Now you can write your contribution, using all the packages you need. Install the required dependencies as usual (via `install.packages()` or via the RStudio IDE) or using **renv** built-in `install()` function:
174
-
175
-
```r
176
-
# Install packages you need
177
-
renv::install("ggplot2") # or equivalently install.packages("ggplot2")
178
-
```
179
-
180
-
Non-CRAN packages (*e.g.* Github packages) can be used. To install such packages, you need to first install the **remotes** package. Then, if you want to install the development version of *e.g.* the **gt** package hosted by `rstudio` GitHub account (useful for nicely and easily formatting tables btw), you would do:
181
-
182
-
```r
183
-
install.packages("remotes")
184
-
remotes::install_github("rstudio/gt")
185
-
```
186
-
187
-
Once you are done, you need to freeze the environment and package versions that are going to be used to run the calculations within your paper. This is achieved via:
The `renv.lock` should be versioned with git. Other files that `renv::snapshot()` might produce should be listed under `.gitignore` and therefore not put under versioning.
196
-
:::
197
-
198
-
More details for using **renv** can be found:
199
-
200
-
- either on the [**renv**](https://rstudio.github.io/renv/articles/renv.html) package website,
201
-
- or on the Quarto website at this [dedicated page](https://quarto.org/docs/projects/virtual-environments.html#using-renv).
0 commit comments