A continuación, se muestra la creación de markdown.
## Rows: 5718608 Columns: 11
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (6): trip_id, bikeid, usertype, month, day, day_of_week
## dbl (2): year, ride_length
## dttm (2): start_time, end_time
## date (1): date
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## trip_id bikeid start_time
## Length:5718608 Length:5718608 Min. :2023-01-01 00:01:58.00
## Class :character Class :character 1st Qu.:2023-05-21 12:45:26.00
## Mode :character Mode :character Median :2023-07-20 17:57:20.00
## Mean :2023-07-16 10:15:57.98
## 3rd Qu.:2023-09-16 20:02:36.50
## Max. :2023-12-31 23:59:38.00
## end_time usertype date
## Min. :2023-01-01 00:02:41.00 Length:5718608 Min. :2023-01-01
## 1st Qu.:2023-05-21 13:08:05.00 Class :character 1st Qu.:2023-05-21
## Median :2023-07-20 18:13:58.00 Mode :character Median :2023-07-20
## Mean :2023-07-16 10:34:09.31 Mean :2023-07-15
## 3rd Qu.:2023-09-16 20:22:21.50 3rd Qu.:2023-09-16
## Max. :2024-01-01 23:50:51.00 Max. :2024-01-01
## month day year day_of_week
## Length:5718608 Length:5718608 Min. :2023 Length:5718608
## Class :character Class :character 1st Qu.:2023 Class :character
## Mode :character Mode :character Median :2023 Mode :character
## Mean :2023
## 3rd Qu.:2023
## Max. :2024
## ride_length
## Min. : 1
## 1st Qu.: 325
## Median : 572
## Mean : 1091
## 3rd Qu.: 1015
## Max. :5909344
viajes %>%
group_by(usertype, bikeid) %>%
summarise(number_of_rides = n()) %>%
ggplot(aes(x = usertype, y = number_of_rides, fill = bikeid)) +
geom_col(position = "dodge") +
labs(title = "Bicicleta más utilizada por tipo de usuario",
x = "Tipo de usuario",
y = "Cantidad de viajes") +
scale_fill_discrete(name = "Tipo de bicicleta")viajes %>%
mutate(weekday = wday(start_time, label = TRUE)) %>%
group_by(usertype, weekday) %>%
summarise(number_of_rides=n()
,average_duration = mean(ride_length)) %>%
arrange(usertype, weekday) %>%
ggplot(aes(x=weekday, y = number_of_rides, fill = usertype)) +
geom_col(position = "dodge") +
labs(title = "Número de viajes por tipo de usuario x dia de semana",
x = "Día de la semana",
y = "Número de viajes") +
scale_y_continuous(labels = scales::comma)viajes %>%
mutate(weekday = wday(start_time, label = TRUE)) %>% # Crea campo weekday usando wday()
group_by(usertype, weekday) %>% # Agrupamos por usertype y weekday.
summarise(number_of_rides = n() # calcula el numero de viajes
,average_duration = mean(ride_length)) %>% # calcula la duración promedio.
arrange(usertype, weekday) %>% #ordenando los datos
ggplot(aes(x = weekday,y = usertype, fill = average_duration)) +
geom_col(position = "dodge") +
labs(title = "Número de viajes y duración promedio por día de la semana y tipo de usuario",
x = "Día de la semana",
y = "Tipo de usuario",
colour = "Duración promedio") +
scale_fill_viridis_c() # viajes %>%
mutate(weekday = wday(start_time, label = TRUE)) %>%
group_by(usertype, weekday) %>%
summarise(number_of_rides=n()
,average_duration = mean(ride_length)) %>%
arrange(usertype, weekday) %>%
ggplot(aes(x=weekday, y = average_duration, fill = usertype)) +
geom_col(position = "dodge")