@@ -47,14 +47,12 @@ rd <- rename(rd, participant_id = ID_PESS ,
4747# Recode modes as strings
4848mode_df <- data.frame (
4949 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' ,
50+ mode_string = c(rep(' bus' , 5 ), rep( ' car ' , 2 ) ,
51+ ' taxi ' , rep( ' van ' , 3 ),
52+ ' subway' ,
5353 ' train' , ' motorbike' ,
5454 ' bicycle' , ' walk' , ' others' , NA )
5555
56-
57-
5856)
5957
6058# Convert numeric to string modes
@@ -86,7 +84,7 @@ ggplot(rd %>%
8684 filter(! is.na(trip_mode )) %> %
8785 group_by(trip_mode ) %> %
8886 summarise(sum_trip_weights = sum(FE_VIA )) %> %
89- mutate(perc = round(sum_trip_weights / sum_total_trip_weight * 100 , 1 )),
87+ mutate(perc = round(sum_trip_weights / sum( sum_trip_weights ) * 100 , 1 )),
9088 aes(x = trip_mode , y = perc )) +
9189 geom_bar(position = ' dodge' , stat = ' identity' ) +
9290 geom_text(aes(label = perc ), position = position_dodge(width = 0.9 ), vjust = - 0.25 , color = " blue" ) +
@@ -118,6 +116,16 @@ ggplot(rd %>%
118116 theme(axis.text.x = element_text(angle = 90 , hjust = 1 )) +
119117 labs(x = " " , y = " percentage(%)" , title = " Main Mode Distance distribution" )
120118
119+ # Calculate mode speed from the dataset, but using mean distance and duration
120+ # Remove all trips with multiple modes
121+ # Using only commute mode as a proxy
122+ mode_speed <- rd %> % filter(is.na(MODO2 ) & is.na(MODO3 ) & is.na(MODO4 ) &
123+ ((MOTIVO_O %in% c(1 , 2 , 3 ) & MOTIVO_D %in% 8 ) |
124+ (MOTIVO_D %in% c(1 , 2 , 3 ) & MOTIVO_O %in% 8 ))
125+ ) %> % group_by(trip_mode ) %> %
126+ summarise(mean (trip_distance ),
127+ speed = (mean(trip_distance )) / (mean(trip_duration ) / 60 ))
128+
121129
122130# source_modes <- c('Bus', 'Walking')
123131# target_modes <- c('Private Car')
0 commit comments