Skip to content

Commit d871877

Browse files
committed
Put in separate files the way to handle dependencies with the three languages.
1 parent 16cfc40 commit d871877

File tree

4 files changed

+66
-63
lines changed

4 files changed

+66
-63
lines changed

site/_handle_dependencies_R.qmd

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
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:
11+
12+
```r
13+
> renv::init()
14+
This project already has a lockfile. What would you like to do?
15+
16+
1: Restore the project from the lockfile.
17+
2: Discard the lockfile and re-initialize the project.
18+
3: Activate the project without snapshotting or installing any packages.
19+
4: Abort project initialization.
20+
```
21+
22+
You should choose **Option 2**, which will extend the message box with:
23+
24+
```r
25+
- Linking packages into the project library ... Done!
26+
- Lockfile written to "~/Projects/computo/my-computo-submission/renv.lock".
27+
- renv activated -- please restart the R session.
28+
```
29+
30+
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:
47+
48+
```r
49+
# Register environment and package versions
50+
renv::snapshot()
51+
```
52+
53+
::: {.callout-warning title="The `renv.lock` file"}
54+
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).
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
More to come.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
More to come.

site/guidelines-authors.qmd

Lines changed: 4 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -134,83 +134,24 @@ You can customize most of the entries in that file except `project:`, `published
134134

135135
### Setup dependencies
136136

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.
138138

139139
::: {.callout-note icon="false" collapse="true"}
140140
#### R users
141141

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:
188-
189-
```r
190-
# Register environment and package versions
191-
renv::snapshot()
192-
```
193-
194-
::: {.callout-warning title="The `renv.lock` file"}
195-
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).
142+
{{< include _handle_dependencies_R.qmd >}}
202143
:::
203144

204145
::: {.callout-tip icon="false" collapse="true"}
205146
#### Python users
206147

207-
More to come.
148+
{{< include _handle_dependencies_python.qmd >}}
208149
:::
209150

210151
::: {.callout-important icon="false" collapse="true"}
211152
#### Julia users
212153

213-
More to come.
154+
{{< include _handle_dependencies_julia.qmd >}}
214155
:::
215156

216157
### Ensure reproducibility

0 commit comments

Comments
 (0)