Skip to content

Commit

Permalink
Update demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Robinlovelace committed Feb 6, 2025
1 parent 219dd91 commit bb80f14
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions p1/p1project/foundations.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,22 @@ crashes |>

```{r}
ac = stats19::get_stats19(year = 2020, type = "collision")
ac
class(ac)
dim(ac)
ac_2021 = stats19::get_stats19(year = 2021, type = "collision")
nrow(ac)
nrow(ac_2021)
# # After googling "combine 2 data frames" let's try rbind
# ??combine
# ?rbind
ac = rbind(ac, ac_2021)
dim(ac)
ac_datetime = c(ac$datetime, ac_2021$datetime)
length(ac_datetime)
range(ac_datetime)
class(ac)
str(ac)
names(ac)
# aggregate this by day to show
# how crash numbers varied over the year
Expand All @@ -70,10 +84,15 @@ ac_by_year |>
ylim(c(0, NA)) +
# geom_smooth() +
# weekly rolling average
geom_line(aes(Date, `Week average`), colour = "blue") +
geom_line(aes(Date, `Week average`), colour = "red") +
theme_minimal()
```

```{r}
# Updated plot with title and legend...
```





Expand All @@ -89,4 +108,6 @@ ac_by_year |>
```{python}
casualty_type_py = ["a", "B", "c"]
casualty_type_py
```
```


0 comments on commit bb80f14

Please sign in to comment.