Skip to content

Commit

Permalink
cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
philipp-baumann committed Jan 22, 2024
1 parent c0b2f44 commit 8a94aaa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
20 changes: 10 additions & 10 deletions dev/running_r_or_shell_code_in_nix_from_r.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ as.vector(x = df, mode ="list")
This is is different for R versions 4.1.3 and below, where you should get an
identical data frame back.

### Run functioned up code and investigate results produced in pure Nix R software environments
### Run functioned up code and investigate results produced in pure Nix Rsoftware environments

To formally validate in a 'System-to-Nix' approach that the object returned from
`as.vector.data.frame()` is before `R` \< 4.2.0, we define a function that runs
Expand Down Expand Up @@ -306,15 +306,15 @@ software packages available from the community.
There was a change introduce in {stringr} 1.5.0; in earlier versions, this
line of code:

```{r, eval = F}
```{r, eval=FALSE}
stringr::str_subset(c("", "a"), "")
```

would return the character `"a"`. However, this behaviour is unexpected:
it really should return an error. This was addressed in versions after
1.5.0:

```{r, eval = F}
```{r, eval=FALSE}
out_system_stringr <- tryCatch(
expr = {stringr::str_subset(c("", "a"), "")},
error = function(e)NULL)
Expand All @@ -324,11 +324,11 @@ Since the code returns an error, we wrap it inside `tryCatch()` and return
`NULL` instead of an error (if we wouldn't do that, this vignette could not
compile!).

Let's build a sub-shell with the latest version of R, but an older version
Let's build a subshell with the latest version of R, but an older version
of `{stringr}`:


```{r, eval = F}
```{r, eval=FALSE}
library("rix")
path_env_stringr <- file.path(".", "_env_stringr_1.4.1")
Expand All @@ -341,10 +341,10 @@ init(
list.files(path = path_env_stringr, all.files = TRUE)
```

The call below generates a `default.nix` file for the sub-shell with the
The call below generates a `default.nix` file for the subshell with the
old version of `{stringr}`:

```{r, eval = F}
```{r, eval=FALSE}
rix(
r_ver = "latest",
r_pkgs = "stringr@1.4.1",
Expand All @@ -353,9 +353,9 @@ rix(
)
```

We can now run the code in the sub-shell
We can now run the code in the subshell

```{r, eval = F}
```{r, eval=FALSE}
out_nix_stringr <- with_nix(
expr = function() stringr::str_subset(c("", "a"), ""),
program = "R",
Expand All @@ -382,7 +382,7 @@ We can now compare the two: the result of the code running in our main session
with the latest version of `{stringr}` and the result of the code running in the
sub-shell with the old version of `{stringr}`:

```{r, eval = F}
```{r, eval=FALSE}
identical(out_system_stringr, out_nix_stringr)
```

Expand Down
18 changes: 9 additions & 9 deletions vignettes/running-r-or-shell-code-in-nix-from-r.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ There was a change introduce in {stringr} 1.5.0; in earlier versions, this
line of code:


```{r eval = F}
```{r eval = FALSE}
stringr::str_subset(c("", "a"), "")
```

Expand All @@ -349,7 +349,7 @@ it really should return an error. This was addressed in versions after
1.5.0:


```{r eval = F}
```{r eval = FALSE}
out_system_stringr <- tryCatch(
expr = {stringr::str_subset(c("", "a"), "")},
error = function(e)NULL)
Expand All @@ -359,12 +359,12 @@ Since the code returns an error, we wrap it inside `tryCatch()` and return
`NULL` instead of an error (if we wouldn't do that, this vignette could not
compile!).

Let's build a sub-shell with the latest version of R, but an older version
Let's build a subshell with the latest version of R, but an older version
of `{stringr}`:



```{r eval = F}
```{r eval = FALSE}
library("rix")
path_env_stringr <- file.path(".", "_env_stringr_1.4.1")
Expand All @@ -377,11 +377,11 @@ init(
list.files(path = path_env_stringr, all.files = TRUE)
```

The call below generates a `default.nix` file for the sub-shell with the
The call below generates a `default.nix` file for the subshell with the
old version of `{stringr}`:


```{r eval = F}
```{r eval = FALSE}
rix(
r_ver = "latest",
r_pkgs = "stringr@1.4.1",
Expand All @@ -390,10 +390,10 @@ rix(
)
```

We can now run the code in the sub-shell
We can now run the code in the subshell


```{r eval = F}
```{r eval = FALSE}
out_nix_stringr <- with_nix(
expr = function() stringr::str_subset(c("", "a"), ""),
program = "R",
Expand Down Expand Up @@ -422,7 +422,7 @@ with the latest version of `{stringr}` and the result of the code running in the
sub-shell with the old version of `{stringr}`:


```{r eval = F}
```{r eval = FALSE}
identical(out_system_stringr, out_nix_stringr)
```

Expand Down

0 comments on commit 8a94aaa

Please sign in to comment.