Skip to content

Commit

Permalink
Merge pull request #1 from opencasestudies/MB_update
Browse files Browse the repository at this point in the history
Updated template to reflect OCSdata package and more recent OCS standards. added more instructions for reader clarity
  • Loading branch information
carriewright11 authored Mar 8, 2022
2 parents cc8506e + 0e3b3e0 commit 3d3d0a6
Show file tree
Hide file tree
Showing 9 changed files with 2,097 additions and 1,000 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
6 changes: 6 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<!-- README.md is generated from README.Rmd. Please edit that file -->

## README

Your case study project should include a README.md file. The README from the [CO2 Emissions](https://www.opencasestudies.org/ocs-bp-co2-emissions) case study is provided here as an example/template:

### Important links

- HTML: https://www.opencasestudies.org/ocs-bp-co2-emissions
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<!-- README.md is generated from README.Rmd. Please edit that file -->

## README

Your case study project should include a README.md file. The README from the [CO2 Emissions](https://www.opencasestudies.org/ocs-bp-co2-emissions) case study is provided here as an example/template:

### Important links

- HTML: https://www.opencasestudies.org/ocs-bp-co2-emissions
Expand Down
Binary file added data/imported/pm25_data_imported.rda
Binary file not shown.
1,752 changes: 876 additions & 876 deletions docs/pm25_data.csv → data/raw/pm25_data.csv

Large diffs are not rendered by default.

877 changes: 877 additions & 0 deletions data/wrangled/wrangled_data.csv

Large diffs are not rendered by default.

Binary file added data/wrangled/wrangled_data.rda
Binary file not shown.
153 changes: 137 additions & 16 deletions index.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ knitr::include_graphics(here::here("img", "mainplot.png"))

####

All case studies should include a disclaimer about the project, licensing info, and proper citation. See below for examples:

#### {.disclaimer_block}

**Disclaimer**: The purpose of the [Open Case Studies](https://opencasestudies.github.io){target="_blank"} project is **to demonstrate the use of various data science methods, tools, and software in the context of messy, real-world data**. A given case study does not cover all aspects of the research process, is not claiming to be the most appropriate way to analyze a given data set, and should not be used in the context of making policy decisions without external consultation from scientific experts.
Expand All @@ -65,13 +67,16 @@ Wright, Carrie and Ontiveros, Michael and Jager, Leah and Taub, Margaret and Hic

####

In this space you should provide an open access link to the case study source files. This is necessary for users to get access to case study data, at a minimum. See the following example from the CO2 Emissions case study:

To access the GitHub repository for this case study see here: https://github.com//opencasestudies/ocs-bp-co2-emissions.
This case study is part of a series of public health case studies for the [Bloomberg American Health Initiative](https://americanhealth.jhu.edu/open-case-studies).


# **Motivation**
***
Begin the case study by describing what will be analyzed and why.

You may use headers and sub-headers like such:

## **Content Header**
***
Expand All @@ -81,9 +86,11 @@ Content content

### **content header additional level**
***
Attach quotes:

> Content for quotes
Attach images:

```{r, echo = FALSE, out.width="800px"}
knitr::include_graphics(here::here("img","content_image.png"))
Expand All @@ -94,18 +101,23 @@ for large images from the web... might do this instead:
<img width="500" src="https://www.frontiersin.org/files/Articles/505570/fpubh-08-00014-HTML/image_m/fpubh-08-00014-t002.jpg">
</p>

... and provide a link to the image source:

##### [[source](https://www.frontiersin.org/articles/10.3389/fpubh.2020.00014/full)]

Use the following syntax scheme for stylizing text:

<u>To underline something:</u>
**Bold**
*Italics*
<u>**underline and bold** </u>
<u>***underline and bold and italics*** </u>

List:
1)makesure there are two spaces
2)after each item to create new line
Create a List:
1) make sure there are two spaces
2) after each item to create new line

Provide references for your images/content:

#### {.reference_block}

Expand All @@ -116,17 +128,19 @@ Yanosky, J. D. et al. Spatio-temporal modeling of particulate air pollution in t

# **Main Questions**
***
List inside the main question block the main questions that we seek to answer with the case study analysis:

#### {.main_question_block}
<b><u> Our main question: </u></b>

1) Question 1
2) Question 2 etc.
2) Question 2 etc. (You may have more than 2)

####

# **Learning Objectives**
***
In this section, discuss the data science and statistical skills, methods, and concepts that will be covered by this case study. An example from the CO2 emissions case study is provided here:

In this case study, we will explore CO2 emission data from around the world.
We will also focus on the US specifically to evaluate patterns of temperatures and natural disaster activity.
Expand Down Expand Up @@ -161,7 +175,7 @@ include_graphics("https://tidyverse.tidyverse.org/logo.png")


***

After discussing the learning objectives, load all the packages used in the case study analysis in the code chunk below:

We will begin by loading the packages that we will need:

Expand All @@ -172,6 +186,8 @@ library(dplyr)
```


Provide a link to the source and briefly explain its use for each package in the following table:

Package | Use
---------- |-------------
[here](https://github.com/jennybc/here_here){target="_blank"} | to easily load and save data
Expand All @@ -180,12 +196,14 @@ library(dplyr)

The first time we use a function, we will use the `::` to indicate which package we are using. Unless we have overlapping function names, this is not necessary, but we will include it here to be informative about where the functions we will use come from.


# **Context**
***
Provide some more details and background on the case study topic and its relation to public health/the world.

# **Limitations**
***
Describe any limitations that exist in this analysis whether it be due to the data itself, methods used, nature of the topic, etc.

There are some important considerations regarding this data analysis to keep in mind:

1) Limitation 1
Expand All @@ -195,8 +213,9 @@ There are some important considerations regarding this data analysis to keep in

# **What are the data?**
***
Describe the data to be analyzed and where it came from in this section.

If you want to make a table about variable info:
If you want to make a table about variable info, use the following table template:

Variable | Details
---------- |-------------
Expand All @@ -205,25 +224,58 @@ Variable | Details

# **Data Import**
***
Describe how to import your case study data files into R or Python:

Put files in docs directory and use `here` package.
Within your case study project folder, put the data files as they came from the source into a 'data/raw/' subfolder and use the `here` package. See the following example:

```{r}
pm <-readr::read_csv(here("docs", "pm25_data.csv"))
pm <-readr::read_csv(here("data", "raw", "pm25_data.csv"))
```

At the end of the data import section, save the imported data as .rda files to allow users to stop and pick up where they left off:

```{r}
save(pm, file = here::here("data", "imported", "pm25_data_imported.rda"))
```


# **Data Exploration and Wrangling**
***
At the beginning of the section, include the following message:

If you have been following along but stopped, we could load our imported data like so:

```{r}
load(here::here("data", "imported", "pm25_data_imported.rda"))
```

Also provide guidance for users who may have skipped the previous section, see the following example:

***
<details> <summary> If you skipped the data import section click here. </summary>

An RDA version (stands for R data) of the data can be found [here](https://github.com//opencasestudies/ocs-bp-co2-emissions/tree/master/data/imported) or slightly more directly [here](https://raw.githubusercontent.com/opencasestudies/ocs-bp-co2-emissions/master/data/imported/co2_data_imported.rda). Download this file and then place it in your current working directory within a subdirectory called "imported" within a directory called "data" to use the following code. We used an RStudio project and the [`here` package](https://github.com/jennybc/here_here) to navigate to the file more easily.

```{r, eval=FALSE}
load(here::here("data", "imported", "co2_data_imported.rda"))
```

</details>
***

Use this section to walk through any exploration of the data conducted pre-analysis. Then, explain step-by-step the data wrangling process used to prepare the data for analysis. Note that not all case studies include a data exploration. Data exploration and wrangling may also be split into two sections.

We will also use the `%>%` pipe which can be used to define the input for later sequential steps. This will make more sense when we have multiple sequential steps using the same data object. To use the pipe notation we need to install and load dplyr as well.

Can add DT tables too- note that you can`t use these inside a click expand details section.
Can include DT tables too:

```{r}
library(DT)
DT::datatable(iris)
```

(note that you can`t use these inside a click expand details section.)

Scrollable content:

#### {.scrollable }
Expand Down Expand Up @@ -263,13 +315,72 @@ pm %>%
```
####

At the end of this section, include the following:

To allow users to skip import and wrangling we will save the data as an RDA file as well as a CSV file as this is often useful to send our data to collaborators. We will save this in a “wrangled” subdirectory of our “data” directory of our working directory.

```{r}
save(pm, file = here::here("data", "wrangled", "wrangled_data.rda"))
readr::write_csv(pm, path = here::here("data","wrangled", "wrangled_data.csv"))
```

Replace `pm` with the name of the data object created at the end of data wrangling.

# **Data Visualization**
***
At the beginning of the section, include the following message:

If you have been following along but stopped, we could load our wrangled data like so:

```{r}
load(here::here("data", "wrangled", "wrangled_data.rda"))
```

Also provide guidance for users who may have skipped the previous section, see the following example:

***
<details> <summary> If you skipped the data import section click here. </summary>

An RDA file (stands for R data) of the data can be found [here](https://github.com//opencasestudies/ocs-bp-co2-emissions/tree/master/data/wrangled) or slightly more directly [here](https://raw.githubusercontent.com/opencasestudies/ocs-bp-co2-emissions/master/data/wrangled/wrangled_data.rda). Download this file and then place it in your current working directory within a subdirectory called "wrangled" within a subdirectory called "data" to use the following code. We used an RStudio project and the [`here` package](https://github.com/jennybc/here_here) to navigate to the file more easily.


```{r}
load(here::here("data", "wrangled", "wrangled_data.rda"))
```

</details>
***

Use this section to walk through step by step how the wrangled data was visualized. Explain how these visualizations improve understanding and help extract insights.

If any further wrangling was conducted in this section, please save the most recent version of the data similar to previous sections.

# **Data Analysis**
***
At the beginning of the section, include the following message:

If you have been following along but stopped, we could load our wrangled data like so:

```{r}
load(here::here("data", "wrangled", "wrangled_data.rda"))
```

Also provide guidance for users who may have skipped the previous section, see the following example:

***
<details> <summary> If you skipped the data import section click here. </summary>

An RDA file (stands for R data) of the data can be found [here](https://github.com//opencasestudies/ocs-bp-co2-emissions/tree/master/data/wrangled) or slightly more directly [here](https://raw.githubusercontent.com/opencasestudies/ocs-bp-co2-emissions/master/data/wrangled/wrangled_data.rda). Download this file and then place it in your current working directory within a subdirectory called "wrangled" within a subdirectory called "data" to use the following code. We used an RStudio project and the [`here` package](https://github.com/jennybc/here_here) to navigate to the file more easily.


```{r}
load(here::here("data", "wrangled", "wrangled_data.rda"))
```

</details>
***

Use this section to walk through the methods and code used in the data analysis step-by-step. Explain how this analysis helps answer the main questions posed earlier in the case study.

## **content header**
***
Expand All @@ -279,18 +390,27 @@ pm %>%

# **Summary**
***

## **Synopsis**
***
Briefly recap everything that was covered in the case study from the motivation to data analysis. Highlight the conclusions made and suggest any limitations or future work to be done.

## **Summary Plot**
***
Construct a plot here that summarizes the conclusions found in the data, if applicable.

## **Suggested Homework**
# **Suggested Homework**
***
Suggest extra exercises using this data for students to practice the skills used in the case study.

Examples from [CO2 case study](https://github.com/opencasestudies/ocs-bp-co2-emissions/):

Ask students to create a plot with labels showing the countries with the lowest CO2 emission levels.

Ask students to plot CO2 emissions and other variables (e.g. energy use) on a scatter plot, calculate the Pearson's correlation coefficient, and discuss results.

# **Additional Information**
***
Use this section to provide any additional information or resources on the topics and methods covered in the case study.

## **Helpful Links**
***
Expand Down Expand Up @@ -331,9 +451,10 @@ guide for [preprocessing with recipes](http://www.rebeccabarter.com/blog/2019-06

## **Session Info**
***

```{r}
library(devtools)
session_info()
devtools::session_info()
```

## **Acknowledgments**
***
***
299 changes: 191 additions & 108 deletions index.html

Large diffs are not rendered by default.

0 comments on commit 3d3d0a6

Please sign in to comment.