Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Commit

Permalink
Update rmd chapter
Browse files Browse the repository at this point in the history
  • Loading branch information
dgkeyes committed Nov 20, 2023
1 parent ee6baaa commit 78327b1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 24 deletions.
Binary file modified nostarch/word/06-rmarkdown_SC_rm_DK.docx
Binary file not shown.
57 changes: 33 additions & 24 deletions rmarkdown.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ output: word_document
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(include = TRUE,
echo = FALSE,
message = FALSE,
warning = FALSE)
knitr::opts_chunk$set(
include = TRUE,
echo = FALSE,
message = FALSE,
warning = FALSE
)
```
```{r}
Expand All @@ -80,16 +82,18 @@ We are writing a report about the **Palmer Penguins**. These penguins are *reall
We can make a histogram to see the distribution of bill lengths.
```{r}
penguins %>%
penguins %>%
ggplot(aes(x = bill_length_mm)) +
geom_histogram() +
theme_minimal()
```
```{r}
average_bill_length <- penguins %>%
summarize(avg_bill_length = mean(bill_length_mm,
na.rm = TRUE)) %>%
average_bill_length <- penguins %>%
summarize(avg_bill_length = mean(
bill_length_mm,
na.rm = TRUE
)) %>%
pull(avg_bill_length)
```
Expand Down Expand Up @@ -172,7 +176,7 @@ R Markdown treats anything in the code chunk as R code when we knit. For example

````{verbatim echo = TRUE, eval = FALSE, lang = "markdown"}
```{r}
penguins %>%
penguins %>%
ggplot(aes(x = bill_length_mm)) +
geom_histogram() +
theme_minimal()
Expand All @@ -182,7 +186,7 @@ penguins %>%
The histogram can be seen in Figure \@ref(fig:simple-histogram).

```{r simple-histogram, fig.cap = "A simple histogram"}
penguins %>%
penguins %>%
ggplot(aes(x = bill_length_mm)) +
geom_histogram() +
theme_minimal()
Expand Down Expand Up @@ -222,10 +226,12 @@ In cases where you’re using R Markdown to generate a report for a non-R user,

````{verbatim echo = TRUE, eval = FALSE, lang = "markdown"}
```{r setup, include = FALSE}
knitr::opts_chunk$set(include = TRUE,
echo = FALSE,
message = FALSE,
warning = FALSE)
knitr::opts_chunk$set(
include = TRUE,
echo = FALSE,
message = FALSE,
warning = FALSE
)
```
````

Expand All @@ -234,7 +240,7 @@ The `include = FALSE` option on the first line applies to the setup code chunk i

````{verbatim echo = TRUE, eval = FALSE, lang = "markdown"}
```{r echo = TRUE}
penguins %>%
penguins %>%
ggplot(aes(x = bill_length_mm)) +
geom_histogram() +
theme_minimal()
Expand Down Expand Up @@ -295,9 +301,11 @@ Inline R code begins with a backtick and the lowercase letter r and ends with an

````{verbatim echo = TRUE, eval = FALSE, lang = "markdown"}
```{r}
average_bill_length <- penguins %>%
summarize(avg_bill_length = mean(bill_length_mm,
na.rm = TRUE)) %>%
average_bill_length <- penguins %>%
summarize(avg_bill_length = mean(
bill_length_mm,
na.rm = TRUE
)) %>%
pull(avg_bill_length)
```
````
Expand Down Expand Up @@ -357,18 +365,20 @@ output: word_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(include = TRUE,
echo = FALSE,
message = FALSE,
warning = FALSE)
knitr::opts_chunk$set(
include = TRUE,
echo = FALSE,
message = FALSE,
warning = FALSE
)
```
```{r}
penguins <- read_csv("https://raw.githubusercontent.com/rfortherestofus/r-without-statistics/main/data/penguins-2008.csv")
```
```{r}
penguins %>%
penguins %>%
ggplot(aes(x = bill_length_mm)) +
geom_histogram() +
theme_minimal()
Expand Down Expand Up @@ -402,4 +412,3 @@ The following resources are great general guides for using R Markdown:
*R Markdown: The Definitive Guide* by Yihui Xie, J. J. Allaire, and Garrett Grolemund (CRC Press, 2019), https://bookdown.org/yihui/rmarkdown/

*R Markdown Cookbook* by Yihui Xie, Christophe Dervieux, Emily Riederer (CRC Press, 2021), https://bookdown.org/yihui/rmarkdown-cookbook/

0 comments on commit 78327b1

Please sign in to comment.