Skip to content

Commit

Permalink
post: fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
ahasverus committed Mar 15, 2024
1 parent 961cb64 commit 34e79cf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,21 @@ Proceed as follow:
- Name: `R_USER`
- Value: `C:\Users\username` (replace `username` by your Windows user name)

After restarting {{< fa brands r-project >}}, the functions `utils::file.edit("~/.Rprofile")` and `usethis::edit_r_profile()` will create (if required) and open the `.Rprofile` file in `C:/Users/username` (not in `C:/Users/username/Documents`).
After restarting {{< fa brands r-project >}}, the `HOME` directory should always point to `C:/Users/username`.

```{r}
#| eval: false
Sys.getenv("R_USER")
## C:/Users/username
path.expand("~")
## C:/Users/username
normalizePath("~")
## C:\\Users\\username
fs::path_home()
## C:/Users/username
```

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ What is a secret? It is usually a password, an username or an API token (key) re
- [`rwosstarter`](https://frbcesab.github.io/rwosstarter/) requires a token to access the [Web of Science API](https://developer.clarivate.com/apis/wos-starter)
- [`rgbif`](https://docs.ropensci.org/rgbif/) requires an username and a password associated by a [GBIF](https://www.gbif.org/) account

It's tempting to record secrets as variables in R scripts. But keep this in mind:<br>
It's tempting to record secrets as variables in R scripts. But keep in mind this:<br>
**Never share your secrets with anyone** (this also includes GitHub).

According to the [documentation of the `httr`](https://httr.r-lib.org/articles/secrets.html) package, there is three secure ways to store your secrets:
Expand Down Expand Up @@ -50,7 +50,7 @@ NAME1=value1
NAME2=value2
```

We can use this file to store our secrets. To open (and create) this `.Renviron` file, run this command:
We can use this file to store our secrets. To open (and create if necessary) the `.Renviron` file, run this command:

```{r}
#| eval: false
Expand All @@ -62,7 +62,7 @@ utils::file.edit("~/.Renviron")
usethis::edit_r_environ()
```

This command will create an `.Renviron` file at the user level (i.e. in his/her `HOME` directory) and all environment variables defined inside will be available for all his/her projects.
This command will create an `.Renviron` file at the user level (i.e. in his/her `HOME` directory) and all environment variables defined inside will be available for all {{< fa brands r-project >}} sessions.

To store a new secret, just add a new line. For instance:

Expand All @@ -87,7 +87,7 @@ Sys.getenv("GITHUB_PAT")
github_pat <- Sys.getenv("GITHUB_PAT")
```

**N.B.** by running `Sys.getenv()` without argument you will print all available envrionment variables.
**N.B.** by running `Sys.getenv()` without argument you will print all available environment variables.


## To go further
Expand Down

0 comments on commit 34e79cf

Please sign in to comment.