Skip to content

Commit

Permalink
Update paper
Browse files Browse the repository at this point in the history
  • Loading branch information
Robinlovelace committed Jul 1, 2024
1 parent a16454d commit d92000a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 75 deletions.
67 changes: 21 additions & 46 deletions paper.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,17 @@ both, leaving 48.1% or 8831 complete records. There was a distinct
seasonal pattern to reporting, with significant increases in summer
months.

Mode of transport of the complainant is shown in
<a href="#tbl-mode" class="quarto-xref">Table 1</a>. Half of cases were
reported by vehicle drivers, a third by cyclists, seven percent by
pedestrians, with over two percent by horse riders and less than one
percent by motorcyclists.
Of the 12656 records with an offence, the most common offences were
Driving without reasonable consideration to others (rt88576) and Driving
without due care and attention (rt88575). This is presented in
**?@tbl-offences**, which shows the number and percentage of records by
offence type, showing the top 6 offence types and the remainder grouped
as ‘Other’. As previously noted, a high proportion of cases did not
include information on the reported offence, with the most common
offences being Driving without reasonable consideration to others
(rt88576), and Driving without due care and attention (rt88575). Within
the road traffic act these offences are related to careless driving and
drivers are subject to similar penalties.

| Offence | Number of records | Percent of records |
|:---|---:|---:|
Expand All @@ -195,11 +201,12 @@ percent by motorcyclists.

Number of convictions by offence type (top 6 and other).

#>
#> cyclist horse rider motorcyclist pedestrian
#> 6312 407 48 1352
#> unknown vehicle driver vehicle passenger
#> 497 9167 579
Vehicle (mostly car and van drivers with dashcams) driver and cyclist
reporters dominate reporting for all records, as illustrated in
<a href="#tbl-mode" class="quarto-xref">Table 1</a>. Half of cases were
reported by vehicle drivers, a third by cyclists, seven percent by
pedestrians, with over two percent by horse riders and less than one
percent by motorcyclists.

<div id="tbl-mode">

Expand All @@ -220,38 +227,6 @@ Table 1: Number of OpSnap records by observer mode.

</div>

</div>

Classification of the committed offence is shown in
<a href="#tbl-offences" class="quarto-xref">Table 2</a>. s previously
noted, a high proportion of cases did not include information on the
reported office (31.1%), with the most common offences being Driving
without reasonable consideration to others (rt88576), and Driving
without due care and attention (rt88575). Within the road traffic act
these offences are related to careless driving and drivers are subject
to similar penalties.

<div id="tbl-offences">

Table 2: Number and percentages of OpSnap records by offence type.

<div class="cell-output-display">

| Offence | N | Percent of Records |
|:---|---:|:---|
| n/a | 5706 | 31.1% |
| rt88576 drive without reasonable consideration to others | 4992 | 27.2% |
| rt88575 drive without due care and attention | 2917 | 15.9% |
| rt88975 drive motor vehicle fail to comply with red / green arrow / lane closure traffic light signals | 1364 | 7.4% |
| rt88971 fail to comply with red traffic light | 679 | 3.7% |
| rt88966 motor vehicle fail to comply with endorsable s36 traffic sign | 411 | 2.2% |
| rv86019 use a handheld phone / device whilst driving a motor vehicle on a road | 357 | 1.9% |
| rt88760 fail to comply with solid white lines | 265 | 1.4% |
| rt88751 contravene give way sign | 264 | 1.4% |
| suspected contravene weight restriction. | 213 | 1.2% |

</div>

</div>
<!-- The equivalent table excluding records with missing offence data is shown below: -->
<!-- For cases submitted by people riding cycles (shown in @tbl-offences-cyclist-observer), the most common offences were also both associated with careless driving, particularly driving without reasonable consideration to others (78.7%), there were also a small proportion of cases associated with drivers using mobile phones (3.7%), failing to comply with traffic signals (3.5%) and contravening regulator signage (0.6%). -->
Expand Down Expand Up @@ -279,7 +254,7 @@ other types of road traffic offence, with pedestrians and others also
more likely to encounter other types of offence.

Disposal categories assigned by police are shown in
<a href="#tbl-disposal" class="quarto-xref">Table 3</a>. Roughly a third
<a href="#tbl-disposal" class="quarto-xref">Table 2</a>. Roughly a third
of cases resulted in no further action, and for most of the remainder
drivers were required to undertake an education course. Conditional
offers, that is, drivers being offered a reduced penalty for admitting
Expand All @@ -289,7 +264,7 @@ underwent further investigation.

<div id="tbl-disposal">

Table 3: Most common disposal values in the OpSnap dataset.
Table 2: Most common disposal values in the OpSnap dataset.

<div class="cell-output-display">

Expand All @@ -310,13 +285,13 @@ Table 3: Most common disposal values in the OpSnap dataset.

There are 8801 unique locations (addresses) in the data, with the most
common locations shown in
<a href="#tbl-locations" class="quarto-xref">Table 4</a>.
<a href="#tbl-locations" class="quarto-xref">Table 3</a>.

INSERT Table 5 AND/OR Map (TO BE INCLUDED)

<div id="tbl-locations">

Table 4: Most common locations recorded in the OpSnap dataset
Table 3: Most common locations recorded in the OpSnap dataset

<div class="cell-output-display">

Expand Down
52 changes: 23 additions & 29 deletions paper.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ browseURL("paper.docx")
```

```{r setup}
library(opsnap)
#| include: false
devtools::load_all()
```

# Abstract {.unnumbered}
Expand Down Expand Up @@ -342,14 +343,15 @@ There were `r nrow(d_all)` records in the dataset for the three-year study perio
Some records lacked either an offence (`r nrow(d_all) - nrow(d_offence)`, `r round((nrow(d_all) - nrow(d_offence)) / nrow(d_all) * 100, 1)`%) or a location (`r nrow(d_offence) - nrow(d_complete)`, `r round((nrow(d_offence) - nrow(d_complete)) / nrow(d_all) * 100, 1)`%), or both, leaving `r round(nrow(d_complete) / nrow(d_all) * 100, 1)`% or `r nrow(d_complete)` complete records.
There was a distinct seasonal pattern to reporting, with significant increases in summer months.


Mode of transport of the complainant is shown in @tbl-mode.
Half of cases were reported by vehicle drivers, a third by cyclists, seven percent by pedestrians, with over two percent by horse riders and less than one percent by motorcyclists.
Of the `r nrow(d_offence)` records with an offence, the most common offences were Driving without reasonable consideration to others (rt88576) and Driving without due care and attention (rt88575).
This is presented in @tbl-offences, which shows the number and percentage of records by offence type, showing the top 6 offence types and the remainder grouped as 'Other'.
As previously noted, a high proportion of cases did not include information on the reported offence, with the most common offences being Driving without reasonable consideration to others (rt88576), and Driving without due care and attention (rt88575).
Within the road traffic act these offences are related to careless driving and drivers are subject to similar penalties.

```{r}
#| label: tbl-mode-offences
#| label: tbl-offences
#| include: true
#| fig-cap: "Number of convictions by offence type (top 6 and other)."
#| tbl-cap: "Number of convictions by offence type (top 6 and other)."
# Aim: get table of n. offences by mode
d_mode_offence_count = d_all |>
count(mode, offence, sort = TRUE)
Expand Down Expand Up @@ -420,7 +422,7 @@ regroup_offences_simple = function(x) {
)
)
}
table(x$mode)
# table(x$mode)
regroup_modes = function(x) {
x |>
dplyr::mutate(
Expand All @@ -436,6 +438,9 @@ d_all = regroup_modes(d_all)
```

Vehicle (mostly car and van drivers with dashcams) driver and cyclist reporters dominate reporting for all records, as illustrated in @tbl-mode.
Half of cases were reported by vehicle drivers, a third by cyclists, seven percent by pedestrians, with over two percent by horse riders and less than one percent by motorcyclists.

```{r}
#| label: tbl-mode
#| tbl-cap: Number of OpSnap records by observer mode.
Expand All @@ -450,23 +455,6 @@ d_all |>
knitr::kable()
```

Classification of the committed offence is shown in @tbl-offences.
s previously noted, a high proportion of cases did not include information on the reported office (31.1%), with the most common offences being Driving without reasonable consideration to others (rt88576), and Driving without due care and attention (rt88575).
Within the road traffic act these offences are related to careless driving and drivers are subject to similar penalties.

```{r}
#| label: tbl-offences
#| tbl-cap: Number and percentages of OpSnap records by offence type.
d_all |>
count(offence, sort = TRUE) |>
mutate(percent_of_records = n / nrow(d_all)) |>
mutate(percent_of_records = scales::percent(round(percent_of_records, 3))) |>
arrange(desc(n)) |>
head(10) |>
rename_all(snakecase::to_title_case) |>
knitr::kable()
```

<!-- The equivalent table excluding records with missing offence data is shown below: -->

```{r}
Expand All @@ -486,8 +474,8 @@ d_all |>
<!-- For cases submitted by people riding cycles (shown in @tbl-offences-cyclist-observer), the most common offences were also both associated with careless driving, particularly driving without reasonable consideration to others (78.7%), there were also a small proportion of cases associated with drivers using mobile phones (3.7%), failing to comply with traffic signals (3.5%) and contravening regulator signage (0.6%). -->

```{r}
#| label: tbl-mode-offences-crosstab
#| fig-cap: Mode of transport from which video was recorded (columns) and offence type (rows), with counts and percentages within each reporting mode.
#| label: tbl-mode-offences-crosstab-prep
# | Offence (grouped) | | Total |
# |-------------------------|---------------|-------|
Expand Down Expand Up @@ -551,15 +539,21 @@ percent_other_cyclist = pivot_combined |> filter(offence_simple == "Other") |> p
percent_other_driver = pivot_combined |> filter(offence_simple == "Other") |> pull(`Driver (%)`)
percent_other_other = pivot_combined |> filter(offence_simple == "Other") |> pull(`Other (%)`)
pivot_combined |>
knitr::kable(digits = 1)
```

The cross-tabulation of reporting mode and offence type is shown in @tbl-mode-offences-crosstab.
The table reveals some interesting tendencies.
While `r round(percent_inconsiderate, 1)` percent of all offences are for inconsiderate driving, they make up the bulk of offences reported by cyclists, with `r round(percent_inconsiderate_cycling, 1)` percent of all offences reported by cyclists being for inconsiderate driving.
Drivers are proportionally `r round(percent_other_driver / percent_other_cyclist, 1)` times more likely to report other types of offences as cyclists, while other reporting modes are most likely to report other types of offences, being `r round(percent_other_other / percent_other_cyclist, 1)` times more likely to report other types of offences as cyclists.
While further research is needed, this makes sense if physically-vulnerable cyclists are most concerned with the dangerous driving of vehicles, whereas drivers also report other types of road traffic offence, with pedestrians and others also more likely to encounter other types of offence.

```{r}
#| label: tbl-mode-offences-crosstab
#| tbl-cap: Mode of transport from which video was recorded (columns) and offence type (rows), with counts and percentages within each reporting mode.
pivot_combined |>
knitr::kable(digits = 1)
```

```{r}
#| label: tbl-offences-cyclist-observer
#| tbl-cap: "Number and percentages of OpSnap records, submitted by cyclists, by offence type."
Expand Down

0 comments on commit d92000a

Please sign in to comment.