Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lwjohnst86 committed Apr 16, 2024
2 parents 0470760 + bba6582 commit 58b9d8a
Show file tree
Hide file tree
Showing 17 changed files with 322 additions and 268 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-website.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: Build Website

on:
push:
branches:
- main

name: build-deploy

jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup R
uses: r-lib/actions/setup-r@v2
Expand Down
8 changes: 5 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ Imports:
stringr,
usethis,
vroom,
withr
withr,
r3admin (>= 0.0.1)
Suggests:
prodigenr,
tidyverse
Remotes:
github::rostools/r3
Remotes:
github::rostools/r3,
rostools/r3admin
Encoding: UTF-8
LazyData: true
1 change: 1 addition & 0 deletions R/pre-course-script.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ unzip(here("data-raw/mmash-data.zip"),
exdir = here("data-raw"),
junkpaths = TRUE
)
Sys.sleep(1)
unzip(here("data-raw/MMASH.zip"),
exdir = here("data-raw")
)
Expand Down
8 changes: 4 additions & 4 deletions R/scrape-physionet.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ library(stringr)

mmash_page <- bow("https://physionet.org/content/mmash/1.0.0/")

mmash_html <- mmash_page %>%
scrape() %>%
mmash_html <- mmash_page |>
scrape() |>
html_node(".col-md-8")

temp_html <- tempfile(fileext = ".html")
Expand All @@ -15,8 +15,8 @@ write_html(mmash_html, temp_html)
temp_md <- tempfile(fileext = ".md")
pandoc_convert(temp_html, to = "markdown_strict", output = temp_md)

readLines(temp_md)[-(8:76)] %>%
str_remove("\\\\") %>%
readLines(temp_md)[-(8:76)] |>
str_remove("\\\\") |>
writeLines(temp_md)

render(
Expand Down
23 changes: 10 additions & 13 deletions appendix/extras.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,11 @@ map(numbers, over_five)

This works great as is, but sometimes you might not need to create a new
function to use inside of `map()`. Instead we could use an anonymous
function with either `function()` or `~`.
function with `\()` (or either `function()` or `~`).

```{r}
# Anonymous function
map(numbers, function(x) if (x > 5) TRUE else FALSE)
# Anonymous function (with shortcut)
map(numbers, ~ if (.x > 5) TRUE else FALSE)
map(numbers, \(x) if (x > 5) TRUE else FALSE)
```

## Debugging functions
Expand Down Expand Up @@ -148,12 +145,12 @@ Here's an example where you want to use your own arguments in

```{r test-nse, error=TRUE}
test_nse <- function(data, filter_condition) {
data %>%
data |>
dplyr::filter(filter_condition)
}
CO2 %>%
tibble() %>%
CO2 |>
tibble() |>
test_nse(conc > 100)
```

Expand All @@ -179,15 +176,15 @@ with `{{}}`.
```{r test-nse-fixed}
#| error: true
test_nse <- function(data, filter_condition) {
data %>%
data |>
dplyr::filter({{ filter_condition }})
}
CO2 %>%
tibble() %>%
CO2 |>
tibble() |>
test_nse(conc > 100)
CO2 %>%
tibble() %>%
CO2 |>
tibble() |>
test_nse(uptake < 30)
```
Binary file modified data/mmash.rda
Binary file not shown.
81 changes: 51 additions & 30 deletions includes/packages.bib
Original file line number Diff line number Diff line change
@@ -1,145 +1,166 @@
@Manual{R-desc,
title = {desc: Manipulate DESCRIPTION Files},
author = {Gábor Csárdi and Kirill Müller and Jim Hester},
year = {2022},
note = {https://github.com/r-lib/desc#readme},
year = {2023},
note = {R package version 1.4.3},
url = {https://desc.r-lib.org/},
}

@Manual{R-downlit,
title = {downlit: Syntax Highlighting and Automatic Linking},
author = {Hadley Wickham},
year = {2022},
note = {https://downlit.r-lib.org/},
year = {2023},
note = {R package version 0.4.3},
url = {https://downlit.r-lib.org/},
}

@Manual{R-dplyr,
title = {dplyr: A Grammar of Data Manipulation},
author = {Hadley Wickham and Romain François and Lionel Henry and Kirill Müller and Davis Vaughan},
year = {2023},
note = {https://dplyr.tidyverse.org},
note = {R package version 1.1.4},
url = {https://dplyr.tidyverse.org},
}

@Manual{R-fs,
title = {fs: Cross-Platform File System Operations Based on libuv},
author = {Jim Hester and Hadley Wickham and Gábor Csárdi},
year = {2023},
note = {https://fs.r-lib.org, https://github.com/r-lib/fs},
note = {R package version 1.6.3},
url = {https://fs.r-lib.org},
}

@Manual{R-glue,
title = {glue: Interpreted String Literals},
author = {Jim Hester and Jennifer Bryan},
year = {2022},
note = {https://github.com/tidyverse/glue},
year = {2024},
note = {R package version 1.7.0},
url = {https://glue.tidyverse.org/},
}

@Manual{R-here,
title = {here: A Simpler Way to Find Your Files},
author = {Kirill Müller},
year = {2020},
note = {https://here.r-lib.org/},
note = {R package version 1.0.1},
url = {https://here.r-lib.org/},
}

@Manual{R-htmltools,
title = {htmltools: Tools for HTML},
author = {Joe Cheng and Carson Sievert and Barret Schloerke and Winston Chang and Yihui Xie and Jeff Allen},
year = {2023},
note = {https://github.com/rstudio/htmltools},
year = {2024},
note = {R package version 0.5.8,
https://rstudio.github.io/htmltools/},
url = {https://github.com/rstudio/htmltools},
}

@Manual{R-knitr,
title = {knitr: A General-Purpose Package for Dynamic Report Generation in R},
author = {Yihui Xie},
year = {2023},
note = {R package version 1.43},
note = {R package version 1.45},
url = {https://yihui.org/knitr/},
}

@Manual{R-magrittr,
title = {magrittr: A Forward-Pipe Operator for R},
author = {Stefan Milton Bache and Hadley Wickham},
year = {2022},
note = {https://magrittr.tidyverse.org},
note = {R package version 2.0.3,
https://github.com/tidyverse/magrittr},
url = {https://magrittr.tidyverse.org},
}

@Manual{R-pak,
title = {pak: Another Approach to Package Installation},
author = {Gábor Csárdi and Jim Hester},
note = {R package version 0.5.1},
year = {2024},
note = {R package version 0.7.2},
url = {https://pak.r-lib.org/},
year = {2023},
}

@Manual{R-prodigenr,
title = {prodigenr: Research Project Directory Generator},
author = {Luke Johnston},
year = {2022},
note = {https://github.com/rostools/prodigenr},
note = {R package version 0.6.2,
https://rostools.github.io/prodigenr/},
url = {https://github.com/rostools/prodigenr},
}

@Manual{R-purrr,
title = {purrr: Functional Programming Tools},
author = {Hadley Wickham and Lionel Henry},
year = {2023},
note = {https://purrr.tidyverse.org/},
note = {R package version 1.0.2},
url = {https://purrr.tidyverse.org/},
}

@Manual{R-r3,
title = {r3: Companion Package for the R3 Courses},
author = {Luke Johnston},
year = {2023},
note = {R package version 0.2.4},
note = {R package version 0.2.5},
url = {https://github.com/rostools/r3},
}

@Manual{R-snakecase,
title = {snakecase: Convert Strings into any Case},
author = {Malte Grosser},
year = {2019},
note = {R package version 0.11.0},
year = {2023},
note = {R package version 0.11.1},
url = {https://github.com/Tazinho/snakecase},
}

@Manual{R-stringr,
title = {stringr: Simple, Consistent Wrappers for Common String Operations},
author = {Hadley Wickham},
year = {2022},
note = {https://stringr.tidyverse.org},
year = {2023},
note = {R package version 1.5.1,
https://github.com/tidyverse/stringr},
url = {https://stringr.tidyverse.org},
}

@Manual{R-styler,
title = {styler: Non-Invasive Pretty Printing of R Code},
author = {Kirill Müller and Lorenz Walthert},
year = {2023},
note = {https://github.com/r-lib/styler},
note = {R package version 1.10.2},
url = {https://github.com/r-lib/styler},
}

@Manual{R-tidyverse,
title = {tidyverse: Easily Install and Load the Tidyverse},
author = {Hadley Wickham},
year = {2023},
note = {https://tidyverse.tidyverse.org},
note = {R package version 2.0.0,
https://github.com/tidyverse/tidyverse},
url = {https://tidyverse.tidyverse.org},
}

@Manual{R-usethis,
title = {usethis: Automate Package and Project Setup},
author = {Hadley Wickham and Jennifer Bryan and Malcolm Barrett},
year = {2022},
note = {https://usethis.r-lib.org},
author = {Hadley Wickham and Jennifer Bryan and Malcolm Barrett and Andy Teucher},
year = {2024},
note = {R package version 2.2.3},
url = {https://usethis.r-lib.org},
}

@Manual{R-vroom,
title = {vroom: Read and Write Rectangular Text Data Quickly},
author = {Jim Hester and Hadley Wickham and Jennifer Bryan},
year = {2023},
note = {https://vroom.r-lib.org},
note = {R package version 1.6.5},
url = {https://vroom.r-lib.org},
}

@Manual{R-withr,
title = {withr: Run Code With Temporarily Modified Global State},
author = {Jim Hester and Lionel Henry and Kirill Müller and Kevin Ushey and Hadley Wickham and Winston Chang},
year = {2022},
note = {https://withr.r-lib.org},
year = {2024},
note = {R package version 3.0.0},
url = {https://withr.r-lib.org},
}

@Book{knitr2015,
Expand Down
9 changes: 0 additions & 9 deletions preamble/_schedule-days.qmd

This file was deleted.

12 changes: 7 additions & 5 deletions preamble/pre-course.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ objectives for this page:
#| echo: false
#| eval: true
#| output: asis
r3admin::read_common("reading-website.md")
cat(r3admin::read_common("reading-website.md"), sep = "\n")
```

## Installing the latest programs {#sec-install-programs}
Expand All @@ -90,7 +90,7 @@ r3admin::read_common("reading-website.md")
#| echo: false
#| eval: true
#| output: asis
r3admin::read_common("installing-programs.md")
cat(r3admin::read_common("installing-programs.md"), sep = "\n")
```

## Installing the R packages {#sec-install-r-packages}
Expand All @@ -99,7 +99,7 @@ r3admin::read_common("installing-programs.md")
#| echo: false
#| eval: true
#| output: asis
r3admin::read_pkg_install("advanced")
cat(r3admin::read_template_pkg_install("advanced"), sep = "\n")
```

## Setting up Git {#sec-setup-git}
Expand Down Expand Up @@ -357,7 +357,7 @@ is tell R to first look for the `.Rproj` file and then start looking for
the file we actually want. This might not make sense yet, but as we go
through the course, you will see why this is important to consider.

::: callout-note
::: {.callout-note appearance="default"}
You don't need to run the below code. But if you want to see the
structure and content of a directory, you can use the `dir_tree()`
function from the `{fs}` package, which means "filesystem", by running
Expand Down Expand Up @@ -493,9 +493,11 @@ either `Ctrl-Shift-A` or `Code -> Reformat Code` menu item. Next, we'll
extract the new `data-raw/MMASH.zip` file using `unzip()` again. Because
we want to keep the folder structure inside this zip file, we won't use
`junkpaths`. Write and execute this code in the `data-raw/mmash.R`
script.
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}
Sys.sleep(1)
unzip(here("data-raw/MMASH.zip"),
exdir = here("data-raw")
)
Expand Down
6 changes: 2 additions & 4 deletions preamble/schedule.csv
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,5 @@ Day 3,10:15,Coffee break and snacks,mug-hot,
Day 3,10:30,Quickly re-arranging data with pivots,laptop-code,../sessions/pivots.html
Day 3,12:15,Lunch,utensils,
Day 3,13:00,Hands-on exercises,briefcase,../sessions/hands-on-work.html
Day 3,15:00,Coffee break and snacks,mug-hot,
Day 3,15:15,Hands-on exercises,laptop-code,../sessions/hands-on-work.html
Day 3,16:20,Closing remarks,person-chalkboard,../sessions/what-next.html
Day 3,16:45,Short survey and farewell,comment-dots,https://docs.google.com/forms/d/e/1FAIpQLSe2gpbN9ExCXyeTfJLgu_poemF0iUtkcihnCunXl3YA4e1hHQ/viewform?usp=sf_link
Day 3,14:20,Closing remarks,person-chalkboard,../sessions/what-next.html
Day 3,14:45,Short survey and farewell,comment-dots,https://docs.google.com/forms/d/e/1FAIpQLSe2gpbN9ExCXyeTfJLgu_poemF0iUtkcihnCunXl3YA4e1hHQ/viewform?usp=sf_link
Loading

0 comments on commit 58b9d8a

Please sign in to comment.