Skip to content

Commit

Permalink
Merge pull request #460 from jhudsl/clif-reproducibility
Browse files Browse the repository at this point in the history
Clif reproducibility
  • Loading branch information
clifmckee authored Jan 6, 2024
2 parents c2cd7ed + c2ba113 commit fe3644d
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 343 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ jobs:
echo "changes=$changes" >> $GITHUB_OUTPUT
git add . --force
git commit -m 'Render preview' || echo "No changes to commit"
git pull --set-upstream origin $branch_name --allow-unrelated-histories --strategy-option=ours
git pull --rebase --set-upstream origin $branch_name --allow-unrelated-histories --strategy-option=ours
git push --force || echo "No changes to commit"
shell: bash

2 changes: 1 addition & 1 deletion docs/_schedule_table.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
| | | | | | |
| [Day 1](docs/module_details/day1.html) | Intro | [HTML](modules/Intro/Intro.html), [PDF](modules/Intro/Intro.pdf) | [Rmd](modules/Intro/Intro.Rmd) | | [Day 1 Cheatsheet](modules/cheatsheets/Day-1.pdf) |
| | RStudio | [HTML](modules/RStudio/RStudio.html), [PDF](modules/RStudio/RStudio.pdf) | [Rmd](modules/RStudio/RStudio.Rmd) | [Lab](modules/RStudio/lab/RStudio_Lab.Rmd), [Key](modules/RStudio/lab/RStudio_Lab_Key.Rmd), [Key HTML](modules/RStudio/lab/RStudio_Lab_Key.html) | |
| | Reproducibility | [HTML](modules/Reproducibility/Reproducibility.html), [PDF](modules/Reproducibility/Reproducibility.pdf) | [Rmd](modules/Reproducibility/Reproducibility.Rmd) | | [Good scientific coding practices](resources/good-scientific-coding-practices.pdf) |
| | Reproducibility | [HTML](modules/Reproducibility/Reproducibility.html), [PDF](modules/Reproducibility/Reproducibility.pdf) | [Rmd](modules/Reproducibility/Reproducibility.Rmd) | [Lab](modules/Reproducibility/lab/Reproducibility_Lab.Rmd), [Key](modules/Reproducibility/lab/Reproducibility_Lab_Key.Rmd), [Key HTML](modules/Reproducibility/lab/Reproducibility_Lab_Key.html) | [Good scientific coding practices](resources/good-scientific-coding-practices.pdf) |
| | | | | | |
| [Day 2](docs/module_details/day2.html) | Basic R | [HTML](modules/Basic_R/Basic_R.html), [PDF](modules/Basic_R/Basic_R.pdf) | [Rmd](modules/Basic_R/Basic_R.Rmd) | [Lab](modules/Basic_R/lab/Basic_R_Lab.Rmd), [Key](modules/Basic_R/lab/Basic_R_Lab_Key.Rmd), [Key HTML](modules/Basic_R/lab/Basic_R_Lab_Key.html) | [Day 2 Cheatsheet](modules/cheatsheets/Day-2.pdf) |
| | Data Input | [HTML](modules/Data_Input/Data_Input.html), [PDF](modules/Data_Input/Data_Input.pdf) | [Rmd](modules/Data_Input/Data_Input.Rmd) | [Lab](modules/Data_Input/lab/Data_Input_Lab.Rmd), [Key](modules/Data_Input/lab/Data_Input_Lab_Key.Rmd), [Key HTML](modules/Data_Input/lab/Data_Input_Lab_Key.html) | [Debugging tips guide](resources/debugging_guide.pdf) |
Expand Down
4 changes: 4 additions & 0 deletions modules/Intro/Intro.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -535,3 +535,7 @@ knitr::include_graphics(here::here("images/the-end-g23b994289_1280.jpg"))

Image by <a href="https://pixabay.com/users/geralt-9301/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=812226">Gerd Altmann</a> from <a href="https://pixabay.com//?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=812226">Pixabay</a>





12 changes: 9 additions & 3 deletions modules/Reproducibility/Reproducibility.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ output:
widescreen: yes
---

```{r include=FALSE}
knitr::opts_chunk$set(echo = FALSE, message = FALSE, comment=FALSE, warning=FALSE)
```


```{r, echo = FALSE, message = FALSE, comment=FALSE}
```{r}
# from these slides: https://docs.google.com/presentation/d/1-cauITbscmnDEDt5IqrZOLlCjyhzEOZY5fqwVY7l8tQ/edit?usp=sharing
library(knitr)
opts_chunk$set(comment = "")
Expand All @@ -17,7 +19,7 @@ suppressPackageStartupMessages(library(dplyr))
library(tidyverse)
library(devtools)
library(remotes)
install.packages("ottrpal")
install.packages("ottrpal", repos = "https://cloud.r-project.org", quiet = TRUE)
library(ottrpal)
```

Expand Down Expand Up @@ -174,6 +176,10 @@ sessionInfo()
knitr::include_graphics("images/session_info.png")
```

## Lab 1

🏠 [Class Website](https://jhudatascience.org/intro_to_r/)
💻 [Lab](https://jhudatascience.org/intro_to_r/modules/Reproducibility/lab/Reproducibility_Lab.Rmd)

## More resources

Expand Down
336 changes: 0 additions & 336 deletions modules/Reproducibility/Reproducibility.html

This file was deleted.

34 changes: 34 additions & 0 deletions modules/Reproducibility/lab/Reproducibility_Lab.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: "Reproducibility Lab"
output: html_document
editor_options:
chunk_output_type: console
---

1. Create two objects in your environment, `x` and `y`. Assign `x` as a vector of numbers 1, 2, and 3. Assign `y` as a vector of numbers 4, 5, and 6. Once complete, check that both objects are visible in your RStudio environment.
```{r}
```

2. Clear your environment. Check that `x` and `y` are no longer in the environment by typing each letter in the console. What is the result?
```{r}
```

3. Check your R session info. Which version of R are you running? Which version of the `knitr` package are you running? Write these details below.
```{r}
```

- R version:
- `knitr` version:

**Bonus / Extra practice**: Create a vector `z` with the numbers 0 to 9. Set the seed for the R random number generator to 1234. Draw 5 numbers at random from `z` using the `sample()` function with `replace = TRUE`. Repeatedly run the code 3 times and note what you observe.
```{r}
```

**Bonus / Extra practice**: Run the `sample()` statement again, but this time without running the `set.seed()` line. What do you notice about the 5 numbers?
```{r}
```
39 changes: 39 additions & 0 deletions modules/Reproducibility/lab/Reproducibility_Lab_Key.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
title: "Reproducibility Lab Key"
output: html_document
editor_options:
chunk_output_type: console
---

1. Create two objects in your environment, `x` and `y`. Assign `x` as a vector of numbers 1, 2, and 3. Assign `y` as a vector of numbers 4, 5, and 6. Once complete, check that both objects are visible in your RStudio environment.
```{r}
x <- c(1, 2, 3)
y <- c(4, 5, 6)
x
y
```

2. Clear your environment. Check that `x` and `y` are no longer in the environment by typing each letter in the console. What is the result?
```{r}
rm(list = ls())
```

3. Check your R session info. Which version of R are you running? Which version of the `knitr` package are you running? Write these details below.
```{r}
sessionInfo()
```

- R version:
- `knitr` version:

**Bonus / Extra practice**: Create a vector `z` with the numbers 0 to 9. Set the seed for the R random number generator to 1234. Draw 5 numbers at random from `z` using the `sample()` function with `replace = TRUE`. Repeatedly run the code 3 times and note what you observe.
```{r}
z <- 0:9
set.seed(1234)
sample(x = z, size = 5, replace = TRUE)
```

**Bonus / Extra practice**: Run the `sample()` statement again, but this time without running the `set.seed()` line. What do you notice about the 5 numbers?
```{r}
sample(x = z, size = 5, replace = TRUE)
```
1 change: 1 addition & 0 deletions resources/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ jhur
jitter
Juneteenth
Kaggle
knitr
Lawlor
lefthand
Leanpub
Expand Down
7 changes: 5 additions & 2 deletions scripts/render_modules.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,20 @@ if (length(lab_files) != 0) {
for (i in 1:length(lab_files)) {
module_name <- stringr::str_split(lab_files, pattern = '/')[[i]][2]
rmarkdown::render(lab_files[i],
output_dir = paste0("modules/", module_name, "/lab"))
output_dir = paste0("modules/", module_name, "/lab"),
envir = new.env())
}
}

# loop thru and render all lecture files to html
# Specific module name will be pulled out based on the dir name in modules/

if (length(lecture_files) != 0) {
for (i in 1:length(lecture_files)) {
module_name <-
stringr::str_split(lecture_files, pattern = '/')[[i]][2]
rmarkdown::render(lecture_files[i],
output_dir = paste0("modules/", module_name))
output_dir = paste0("modules/", module_name),
envir = new.env())
}
}

0 comments on commit fe3644d

Please sign in to comment.