-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsession_04_materials.Rmd
More file actions
55 lines (44 loc) · 1.72 KB
/
session_04_materials.Rmd
File metadata and controls
55 lines (44 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
---
title: Session 4 — Materials
date: "August 8, 2018"
---
```{r include=FALSE}
knitr::opts_chunk$set(echo = FALSE, results = 'asis')
make_listing <- function(filename, path_rel, base_url = "https://gerkelab.github.io/core-r-course") {
cat(glue::glue('\n- [{filename}]({path_rel})\n\n ```\n download.file("{file.path(base_url, path_rel)}", "{filename}")\n ```\n\n'))
}
needs_zip <- function(zipfile, dirpath) {
zipfile <- here::here(dirpath, "..", zipfile)
if (!file.exists(zipfile)) return(TRUE)
zip_modtime <- fs::file_info(zipfile)$modification_time
files_modtime <- fs::file_info(fs::dir_ls(dirpath)) %>% pull(modification_time) %>% max()
zip_modtime < files_modtime
}
SESSION <- "04"
ZIPFILE <- glue::glue("core-r_session-{SESSION}_materials.zip")
SESSION_DIR <- file.path("materials", SESSION)
```
Materials for [Session 4](session_04.html).
## Zip File
```{r}
if (needs_zip(ZIPFILE, SESSION_DIR)) {
xfun::in_dir(file.path("materials", SESSION), {
utils::zip(zipfile = file.path("../../materials", ZIPFILE),
files = dir(pattern = "\\.(R|csv|xlsx)"),
extras = "-x *.DS_Store")
})
}
make_listing(ZIPFILE, file.path("materials", ZIPFILE))
```
## Individual Files
The following files simulate a cancer registry data export for patients with breast cancer.
:::{.bs-callout .bs-callout-warning}
**Note** This data is simulated with fictitious record numbers, patient information, and dates, and is intended for Moffitt staff training purposes only.
:::
```{r}
fs::file_info(fs::dir_ls(SESSION_DIR, regexp = "\\.(R|csv|xlsx)")) %>%
mutate(path_rel = fs::path_rel(path, here::here())) %>%
select(path_rel) %>%
mutate(filename = basename(path_rel)) %>%
purrr::pwalk(make_listing)
```