Skip to content

Commit b256616

Browse files
committed
update session 4 - eval settings
Update eval settings in multiple chunks to allow visualisations and specific operations to execute.
1 parent 18c761a commit b256616

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

s4/index.qmd

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "Session 4: Origin-destination data"
33
toc: true
44
execute:
55
cache: true
6-
#eval: true
6+
eval: true
77
warning: false
88
message: false
99
bibliography: ../tds.bib
@@ -17,9 +17,9 @@ In this session, we will learn how to use origin-destination data. To do that we
1717

1818
- We will start with reviewing the homework from the previous session
1919
- A short lecture on origin-destination data (see [slides](https://docs.google.com/presentation/d/1fKXK1ocCSkTQkTQn0eoYWURIfQuFgQwICFiDGVetMek/edit?usp=sharing))
20-
- Practical session working with various data, including analysing origin-destination trip flows in London Cycle Hire System.
20+
- Practical session working with various data, including analysing origin-destination in Bristol and origin-destination flows in London Cycle Hire System.
2121
- Bonus: Geometry operations and spatial analysis
22-
- Homework and next session
22+
- Homework
2323

2424
# Review Homework
2525

@@ -102,7 +102,6 @@ We will start with a simple map of the world. Load the `world` object from the `
102102
::: {.panel-tabset}
103103
## R
104104
```{r}
105-
#| eval: false
106105
#| echo: true
107106
#| output: false
108107
world = spData::world
@@ -124,7 +123,6 @@ Use some basic R functions to explore the `world` object. e.g. `class(world)`, `
124123
::: {.panel-tabset}
125124
## R
126125
```{r}
127-
#| eval: false
128126
#| warning: false
129127
plot(world)
130128
```
@@ -148,7 +146,7 @@ Note that this makes a map of each column in the data frame. Try some other plot
148146
::: {.panel-tabset}
149147
## R
150148
```{r}
151-
#| eval: false
149+
152150
plot(world[3:6])
153151
plot(world["pop"])
154152
```
@@ -173,7 +171,6 @@ Load the `nz` and `nz_height` datasets from the `spData` package.
173171
::: {.panel-tabset}
174172
## R
175173
```{r}
176-
#| eval: false
177174
#| echo: true
178175
#| output: false
179176
nz = spData::nz
@@ -192,7 +189,6 @@ We can use `tidyverse` functions like `filter` and `select` on `sf` objects in t
192189
::: {.panel-tabset}
193190
## R
194191
```{r}
195-
#| eval: false
196192
#| echo: true
197193
#| output: false
198194
canterbury = nz |> filter(Name == "Canterbury")
@@ -213,7 +209,7 @@ This syntax is not very clear. But is the equivalent to
213209
## R
214210
```{r}
215211
#| echo: true
216-
#| eval: false
212+
217213
canterbury_height = nz_height[canterbury, , op = st_intersects]
218214
```
219215

@@ -249,7 +245,6 @@ In this section we will look at basic transport data in the R package **stplanr*
249245
Load the `stplanr` package as follows:
250246

251247
```{r}
252-
#| eval: false
253248
#| echo: true
254249
#| output: false
255250
library(stplanr)
@@ -264,7 +259,6 @@ First we will load some sample data:
264259
::: {.panel-tabset}
265260
## R
266261
```{r}
267-
#| eval: false
268262
#| echo: true
269263
od_data = stplanr::od_data_sample
270264
zone = stplanr::cents_sf
@@ -284,7 +278,6 @@ Now we will rename one of the columns from `foot` to `walk`
284278
::: {.panel-tabset}
285279
## R
286280
```{r}
287-
#| eval: false
288281
#| echo: true
289282
od_data = od_data |>
290283
rename(walk = foot)
@@ -303,7 +296,7 @@ Next we will made a new dataset `od_data_walk` by taking `od_data` and piping it
303296

304297
## R
305298
```{r}
306-
#| eval: false
299+
307300
#| echo: true
308301
od_data_walk = od_data |>
309302
filter(walk > 0) |>
@@ -325,7 +318,6 @@ We can use the generic `plot` function to view the relationships between variabl
325318
::: {.panel-tabset}
326319
## R
327320
```{r}
328-
#| eval: false
329321
plot(od_data_walk)
330322
```
331323

@@ -341,7 +333,6 @@ R has built in modelling functions such as `lm` lets make a simple model to pred
341333
::: {.panel-tabset}
342334
## R
343335
```{r}
344-
#| eval: false
345336
#| echo: true
346337
model1 = lm(proportion_walk ~ proportion_drive, data = od_data_walk)
347338
od_data_walk$proportion_walk_predicted = model1$fitted.values
@@ -363,7 +354,6 @@ We can use the `ggplot2` package to graph our model predictions.
363354
::: {.panel-tabset}
364355
## R
365356
```{r}
366-
#| eval: false
367357
ggplot(od_data_walk) +
368358
geom_point(aes(proportion_drive, proportion_walk)) +
369359
geom_line(aes(proportion_drive, proportion_walk_predicted))
@@ -431,7 +421,7 @@ print(f"Percentage of OD pairs where at least one person walks: {percentage_walk
431421
### R
432422
```{r}
433423
#| eval: false
434-
#|
424+
435425
od_data = od_data |>
436426
filter(bicycle > 0) |>
437427
mutate(perc_cycle = (bicycle / all) * 100)
@@ -566,7 +556,6 @@ We need the `stplanr` package which provides many useful functions for transport
566556
```{r}
567557
#| echo: true
568558
#| output: false
569-
#| eval: true
570559
library(stplanr)
571560
library(tmap)
572561
```

0 commit comments

Comments
 (0)