California Transit Payments
Setting up R Packages
Plot Theme
Show the Code
# https://stackoverflow.com/questions/74491138/ggplot-custom-fonts-not-working-in-quarto
# Chunk options
knitr::opts_chunk$set(
fig.width = 7,
fig.asp = 0.618, # Golden Ratio
# out.width = "80%",
fig.align = "center"
)
### Ggplot Theme
### https://rpubs.com/mclaire19/ggplot2-custom-themes
theme_custom <- function() {
font <- "Roboto Condensed" # assign font family up front
theme_classic(base_size = 14) %+replace% # replace elements we want to change
theme(
panel.grid.minor = element_blank(), # strip minor gridlines
text = element_text(family = font),
# text elements
plot.title = element_text( # title
family = font, # set font family
size = 20, # set font size
face = "bold", # bold typeface
hjust = 0, # left align
# vjust = 2 #raise slightly
margin = margin(0, 0, 10, 0)
),
plot.subtitle = element_text( # subtitle
family = font, # font family
size = 14, # font size
hjust = 0,
margin = margin(2, 0, 5, 0)
),
plot.caption = element_text( # caption
family = font, # font family
size = 8, # font size
hjust = 1
), # right align
axis.title = element_text( # axis titles
family = font, # font family
size = 10 # font size
),
axis.text = element_text( # axis text
family = font, # axis family
size = 8
) # font size
)
}
# Set graph theme
theme_set(new = theme_custom())
#
Introduction
This dataset is the result of a research study on payment options for people using public transit in California.
The dataset is available on Dataset Dryad:
Pike, Susan (2022). Transit payment preferences of unbanked passengers. Dataset Dryad. https://doi.org/10.25338/B8R04T
And a brief 2-pager on the research methodology is here.
Yes, peasants, you should read such stuff from other very different domains!
Read the Data
Data Dictionary
Quantitative Variables
Write in.
Qualitative Variables
Write in.
Observations
Write in.
Data Munging
Summarize and Prepare the Data
Let’s label the data variables…
tibble [204 × 5] (S3: tbl_df/tbl/data.frame)
$ phone.wifi : num [1:204] 1 1 2 1 1 2 1 1 1 2 ...
..- attr(*, "label")= Named chr "Wi_Fi access?"
.. ..- attr(*, "names")= chr "phone.wifi"
..- attr(*, "labels")= Named num [1:2] 1 2
.. ..- attr(*, "names")= chr [1:2] "No" "Yes"
$ phone.money : num [1:204] 1 1 1 1 1 1 1 1 1 2 ...
..- attr(*, "label")= Named chr "Ways to add money?"
.. ..- attr(*, "names")= chr "phone.money"
..- attr(*, "labels")= Named num [1:2] 1 2
.. ..- attr(*, "names")= chr [1:2] "No" "Yes"
$ phone.identity: num [1:204] 1 1 2 2 1 1 2 1 1 2 ...
..- attr(*, "label")= Named chr "Identity Concerns?"
.. ..- attr(*, "names")= chr "phone.identity"
..- attr(*, "labels")= Named num [1:2] 1 2
.. ..- attr(*, "names")= chr [1:2] "No" "Yes"
$ phone.fees : num [1:204] 1 2 1 1 1 1 1 1 1 1 ...
..- attr(*, "label")= Named chr "Monthly Fees?"
.. ..- attr(*, "names")= chr "phone.fees"
..- attr(*, "labels")= Named num [1:2] 1 2
.. ..- attr(*, "names")= chr [1:2] "No" "Yes"
$ phone.balance : num [1:204] 1 2 1 1 1 1 1 2 1 2 ...
..- attr(*, "label")= Named chr "Knowing the balance?"
.. ..- attr(*, "names")= chr "phone.balance"
..- attr(*, "labels")= Named num [1:2] 1 2
.. ..- attr(*, "names")= chr [1:2] "No" "Yes"
Plot the Data
Task and Discussion
Complete the Data Dictionary. Select and Transform the variables as shown. Create the graph shown below and discuss the following questions:
- Identify the type of charts
- Identify the variables used for various geometrical aspects (x, y, fill…). Name the variables appropriately.
- What activity might have been carried out to obtain the data graphed here? Provide some details.
- What would be your recommendation to the Transport Company?
- To the Phone Companies?