##Setting up my r environment notes that I set up my environment by loading the tidyverse package, and import csv divvy data_trip by month, in this case for apr 2022 as bike_trip_apr and duplicate check
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.4.4 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
bike_trip_apr <- read_csv("202204-divvy-tripdata.csv")
## Rows: 371249 Columns: 13
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (7): ride_id, rideable_type, start_station_name, start_station_id, end_...
## dbl (4): start_lat, start_lng, end_lat, end_lng
## dttm (2): started_at, ended_at
##
## ℹ 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.
unique_bike_trip_apr <- bike_trip_apr[!duplicated(bike_trip_apr),]
Dataset is imported by month in RStudio, then duplicates are checked and removed.However on close observation, the dataset is very organised, as there are no duplicates in all the months 2022/2023
##Using pipe function
apr_rides <- unique_bike_trip_apr %>%
rename(starts_ride = started_at, ends_ride = ended_at) %>%
select(ride_id, rideable_type, starts_ride, ends_ride, start_lat, start_lng, end_lat, end_lng, member_casual)
this operation allows for extracting the data using the pipe function, using rename I change the names of some columns in making them more consistent ie started_at to starts_ride and ended_at to ends_ride and with select, only few columns are chosen for view. Same codes are repeated for every month
#export bike_trips_apr by months as csv
write.csv(apr_rides, file = “apr_rides.csv”, row.names = F)
export of monthly data for further statistical analysis, for 2022, export as “month_name_rides” while for 2023 export as “month_name_1_rides”