Skip to content

Commit 97f6894

Browse files
committed
Recode modes as strings and plot their distribution
1 parent 16a9f83 commit 97f6894

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

code/scenarios/sao paulo/streamline_travel_survey.R

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,26 @@ rd <- rename(rd, participant_id = ID_PESS ,
4343
row_id = ID_ORDEM
4444

4545
)
46+
47+
# Recode modes as strings
48+
mode_df <- data.frame(
49+
mode_int = append(c(1:17), NA),
50+
mode_string = c(rep('bus', 5), 'car_driver',
51+
'car_passenger', 'taxi',
52+
rep('van', 3), 'subway',
53+
'train', 'motorbike',
54+
'bicycle', 'walk', 'others', 'NAs')
55+
56+
57+
58+
)
59+
60+
rd$mode_string <- as.character(mode_df$mode_string[match(rd$mode, mode_df$mode_int)])
61+
62+
ggplot(rd %>%
63+
group_by(mode_string) %>%
64+
summarise(count = n()) %>%
65+
mutate(perc = round(count/sum(count) * 100, 1)),
66+
aes(x = mode_string, y = perc)) +
67+
geom_bar(stat="identity") +
68+
theme(axis.text.x = element_text(angle = 90, hjust = 1, size = rel(0.8)))

0 commit comments

Comments
 (0)