You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix nested code chunk display syntax and internal data loading
- Replace knitr '{{r}}' syntax with standard Markdown four-backticks for displaying code chunks.
- Update the example setup chunk to load and clean raw data internally, avoiding dependencies on intermediate files from previous episodes.
# Read raw data and apply cleaning steps from previous episodes
30
+
books2 <- read_csv("data/books.csv") %>%
31
+
rename(
32
+
title = X245.ab,
33
+
author = X245.c,
34
+
callnumber = CALL...BIBLIO.,
35
+
isbn = ISN,
36
+
pubyear = X008.Date.One,
37
+
subCollection = BCODE1,
38
+
format = BCODE2,
39
+
location = LOCATION,
40
+
tot_chkout = TOT.CHKOUT,
41
+
loutdate = LOUTDATE,
42
+
subject = SUBJECT,
43
+
callnumber2 = CALL...ITEM.
44
+
) %>%
45
+
mutate(
46
+
pubyear = as.integer(pubyear),
47
+
subCollection = recode(subCollection,
48
+
"-" = "general collection",
49
+
u = "government documents",
50
+
r = "reference",
51
+
b = "k-12 materials",
52
+
j = "juvenile",
53
+
s = "special collections",
54
+
c = "computer files",
55
+
t = "theses",
56
+
a = "archives",
57
+
z = "reserves"
58
+
),
59
+
format = recode(format,
60
+
a = "book",
61
+
e = "serial",
62
+
w = "microform",
63
+
s = "e-gov doc",
64
+
o = "map",
65
+
n = "database",
66
+
k = "cd-rom",
67
+
m = "image",
68
+
"5" = "kit/object",
69
+
"4" = "online video"
70
+
)
71
+
)
30
72
```
31
73
32
74
## Introduction to Reproducible Reporting
@@ -87,10 +129,12 @@ The white space is where you write your narrative. You use **Markdown** syntax t
87
129
88
130
Code chunks are where your R code lives. They start with ` ```{r} ` and end with ` ``` `.
89
131
90
-
```{{r}}
132
+
````
133
+
```{r}
91
134
# This is a code chunk
92
135
summary(cars)
93
136
```
137
+
````
94
138
95
139
You can insert a new chunk by clicking the **+C** button in the editor toolbar, or by pressing <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>I</kbd> (Windows/Linux) or <kbd>Cmd</kbd>+<kbd>Option</kbd>+<kbd>I</kbd> (Mac).
96
140
@@ -99,15 +143,28 @@ You can insert a new chunk by clicking the **+C** button in the editor toolbar,
99
143
Let's clean up the example file and create a report using our `books` data.
100
144
101
145
1. Delete everything in the file *below* the YAML header.
102
-
2. Add a new **setup** code chunk to load our libraries and data. It is good practice to label this chunk `setup`.
146
+
2. Add a new **setup** code chunk to load our libraries and prepare the data.
Setting `#| echo: false` will display the *plot* in the report, but hide the R *code* that generated it. This is often preferred for reports intended for non-coders.
158
217
@@ -188,14 +247,16 @@ Add this to your document:
188
247
The table below shows the average checkouts for each item format.
0 commit comments