Skip to content

Commit

Permalink
docs(sessions): add execution location context to code blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
lwjohnst86 committed Apr 29, 2024
1 parent 5039b2d commit 549e49c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
20 changes: 20 additions & 0 deletions preamble/pre-course.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ haven't used it, please do these tasks:
type in the RStudio Console:

``` r
#| filename: Console
# A pop-up to type in your name (first and last),
# as well as your email
r3::setup_git_config()
Expand All @@ -138,6 +139,7 @@ Regardless of whether you've done the steps above or not, *everyone*
needs to run:

``` r
#| filename: Console
r3::check_setup()
```

Expand Down Expand Up @@ -204,6 +206,7 @@ by either:
`prodigenr::setup_project("~/Desktop/LearnR3")` in the R Console.

```{r admin-create-project}
#| filename: Console
#| include: false
prodigenr::setup_project(project_path)
```
Expand All @@ -212,6 +215,7 @@ When the RStudio Project opens up again, run these three commands in the
R Console:

``` r
#| filename: Console
prodigenr::setup_with_git()
usethis::use_blank_slate()
usethis::use_r("functions", open = FALSE)
Expand Down Expand Up @@ -253,6 +257,7 @@ analysis. Please do these two tasks:
`learning.qmd` in the `doc/` folder.

``` r
#| filename: Console
r3::create_qmd_doc()
```

Expand Down Expand Up @@ -300,6 +305,7 @@ the dataset to prepare it for later processing. While in your `LearnR3`
R Project, go to the Console pane in RStudio and type out:

``` r
#| filename: Console
usethis::use_data_raw("mmash")
```

Expand All @@ -324,6 +330,7 @@ added there by default. Then we'll create a new line at the top and type
out:

```{r data-raw-script-add-here}
#| filename: "data-raw/mmash.R"
library(here)
```

Expand Down Expand Up @@ -365,6 +372,7 @@ function from the `{fs}` package, which means "filesystem", by running
the following code in the R Console:

``` r
#| filename: "Console"
# To print the file list.
fs::dir_tree("~/Desktop/LearnR3", recurse = 1)
```
Expand All @@ -384,6 +392,7 @@ Alright, the next step is to download the dataset. Paste this code into
the `data-raw/mmash.R` script:

``` r
#| filename: "data-raw/mmash.R"
mmash_link <- "https://physionet.org/static/published-projects/mmash/multilevel-monitoring-of-activity-and-sleep-in-healthy-people-1.0.0.zip"
```

Expand All @@ -398,6 +407,7 @@ be written in the `data-raw/mmash.R` file. Run these lines of code to
download the dataset.

``` r
#| filename: "data-raw/mmash.R"
download.file(mmash_link, destfile = here("data-raw/mmash-data.zip"))
```

Expand All @@ -415,6 +425,7 @@ in the `data-raw/` folder), comment out this line, so that inside the
`data-raw/mmash.R` script it looks like:

``` r
#| filename: "data-raw/mmash.R"
# download.file(mmash_link, destfile = here("data-raw/mmash-data.zip"))
```

Expand All @@ -427,6 +438,7 @@ list by typing out and run this code in the Console. You only need to do
this once.

``` r
#| filename: "Console"
usethis::use_git_ignore("data-raw/mmash-data.zip")
```

Expand Down Expand Up @@ -480,6 +492,7 @@ extract everything to the `data-raw/` folder (no idea why it's called
`data-raw/mmash.R` script.

```{r unzip-main-file}
#| filename: "data-raw/mmash.R"
unzip(here("data-raw/mmash-data.zip"),
exdir = here("data-raw"),
junkpaths = TRUE
Expand All @@ -498,6 +511,7 @@ script. We'll also add a `Sys.sleep(1)` to pause the script for a second
because sometimes the unzipping can be too fast and cause problems.

```{r unzip-data-file}
#| filename: "data-raw/mmash.R"
Sys.sleep(1)
unzip(here("data-raw/MMASH.zip"),
exdir = here("data-raw")
Expand All @@ -513,6 +527,7 @@ usethis::with_project(
exdir = "data-raw",
junkpaths = TRUE
)
Sys.sleep(1)
unzip("data-raw/MMASH.zip",
exdir = "data-raw"
)
Expand All @@ -527,6 +542,7 @@ look into the `data-raw/` folder and confirm that the below listed files
and folders are there.

``` r
#| filename: "Console"
# NOTE: You don't need to run this code,
# its here to show how we got the file list.
fs::dir_tree("data-raw", recurse = 1)
Expand Down Expand Up @@ -554,6 +570,7 @@ new folder `data-raw/DataPaper/` to something more explicit like
script and run them:

```{r delete-rename-files}
#| filename: "data-raw/mmash.R"
library(fs)
file_delete(here(c(
"data-raw/MMASH.zip",
Expand Down Expand Up @@ -603,6 +620,7 @@ us, we don't need to have Git track it. So, in the Console, type out and
run this command:

``` r
#| filename: "Console"
usethis::use_git_ignore("data-raw/mmash/")
```

Expand All @@ -619,6 +637,7 @@ usethis::with_project(
The `data-raw/mmash.R` script should look like this at this point:

```{r pre-course-state-of-script}
#| filename: "data-raw/mmash.R"
#| file: R/pre-course-script.R
#| eval: false
```
Expand All @@ -636,6 +655,7 @@ You now have the data ready for the course! At this point, please run
this function in the Console:

``` r
#| filename: "Console"
r3::check_project_setup()
```

Expand Down
6 changes: 3 additions & 3 deletions sessions/introduction.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ the next steps. But first, we need to do a few things. Since we did all
that work in the pre-course tasks downloading the data and unzipping it,
we need to save these changes to the Git history. Open the Git interface
with either the Git icon at the top near the menu bar, or with
{{< var keybind.git >}}. When the Git inferface opens up we'll click the
{{< var keybind.git >}}. When the Git interface opens up we'll click the
checkbox beside the `.gitignore` and `data-raw/mmash.R` files. Then we
write a commit message in the text box on the right, something like
`Code to download data zip file`. Click the "Commit" button and close
Expand All @@ -238,7 +238,7 @@ Next, delete these two files we don't need by using the `{fs}` package.

In the **Console**, type out:

``` r
``` {.r filename="Console"}
fs::file_delete("TODO.md")
fs::file_delete("doc/report.Rmd")
```
Expand All @@ -247,7 +247,7 @@ Then, open up the `README.md` and fix some of the TODO items. After
cleaning everything up, now we need to use Git to add and commit all the
current files into the history. Open up the Git interface in RStudio
with {{< var keybind.git >}} or through the Git button. Write a message
in the commit textbox saying `Added initial files`.
in the commit text box saying `Added initial files`.

## Styling your files

Expand Down

0 comments on commit 549e49c

Please sign in to comment.