SCRIPT EN R DEL CAPSTONE
P1.- Load necessary libraries:
[Link](“tydiverse”)
1.-library(tidyverse)
4.-library(readr)
6.-library(lubridate)
8.-library(tidyr)
9.-library(ggplot2)
[Link](“data,table”)
7.-library([Link])
[Link]("here")
[Link]("skimr")
2.-library(skimr)
[Link]("janitor")
3.-library(janitor)
[Link]("dplyr")
5.-library(dplyr)
1.-library(tidyverse)
2.-library(skimr)
3.-library(janitor)
4.-library(readr)
5.-library(dplyr)
6.-library(lubridate)
7.-library([Link])
8.-library(tidyr)
9.-library(ggplot2)
> [Link]("tidyverse")
trying URL '[Link]
Content type 'application/x-gzip' length 422995 bytes (413 KB)
==================================================
downloaded 413 KB
The downloaded binary packages are in
/var/folders/74/gvw9kx857cb62z_pccjfchkh0000gn/T//Rtmpa5N8sz/downloaded_packa
ges
> [Link]("tidyverse")
trying URL '[Link]
Content type 'application/x-gzip' length 422995 bytes (413 KB)
==================================================
downloaded 413 KB
The downloaded binary packages are in
/var/folders/74/gvw9kx857cb62z_pccjfchkh0000gn/T//Rtmpa5N8sz/downloaded_packa
ges
> library(tidyverse)
── Attaching core tidyverse packages
──────────────────────────────────────────────────
────────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.4
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ ggplot2 3.5.0 ✔ tibble 3.2.1
✔ lubridate 1.9.3 ✔ tidyr 1.3.0
✔ purrr 1.0.2
── Conflicts
──────────────────────────────────────────────────
────────────────────────────────────────────
tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<[Link] to force all conflicts to
become errors
> library(readr)
> library(lubridate)
> library(lubridate)
> library(tidyr)
> [Link]("[Link]")
There is a binary version available but the source version is later:
binary source needs_compilation
[Link] 1.14.10 1.15.4 TRUE
Do you want to install from sources the package which needs compilation?
(Yes/no/cancel) no
trying URL '[Link]
Content type 'application/x-gzip' length 2343663 bytes (2.2 MB)
==================================================
downloaded 2.2 MB
The downloaded binary packages are in
/var/folders/74/gvw9kx857cb62z_pccjfchkh0000gn/T//Rtmpa5N8sz/downloaded_packa
ges
> library(ggplot2)
> [Link]("here")
trying URL '[Link]
Content type 'application/x-gzip' length 51881 bytes (50 KB)
==================================================
downloaded 50 KB
The downloaded binary packages are in
/var/folders/74/gvw9kx857cb62z_pccjfchkh0000gn/T//Rtmpa5N8sz/downloaded_packa
ges
> [Link]("skimr")
trying URL '[Link]
Content type 'application/x-gzip' length 1213843 bytes (1.2 MB)
==================================================
downloaded 1.2 MB
The downloaded binary packages are in
/var/folders/74/gvw9kx857cb62z_pccjfchkh0000gn/T//Rtmpa5N8sz/downloaded_packa
ges
> [Link]("janitor")
trying URL '[Link]
Content type 'application/x-gzip' length 281553 bytes (274 KB)
==================================================
downloaded 274 KB
The downloaded binary packages are in
/var/folders/74/gvw9kx857cb62z_pccjfchkh0000gn/T//Rtmpa5N8sz/downloaded_packa
ges
> library(janitor)
Attaching package: ‘janitor’
The following objects are masked from ‘package:stats’:
[Link], [Link]
> [Link]("dplyr")
Error in [Link] : Updating loaded packages
> [Link]("dplyr")
trying URL '[Link]
Content type 'application/x-gzip' length 1570597 bytes (1.5 MB)
==================================================
downloaded 1.5 MB
The downloaded binary packages are in
/var/folders/74/gvw9kx857cb62z_pccjfchkh0000gn/T//Rtmpa5N8sz/downloaded_packa
ges
> library(dplyr)
EXPORTAR UN DATASET DE R A UN ARCHIVO CSV EN
EL COMPUTADOR
[Link](df, "C:\\Users\\Ron\\Desktop\\Test\\
my_products.csv", [Link]=FALSE)
[Link](tripdata_202406,”Macintosh HD\\Users\\user\\Desktop\\1CaseStudy1v1\\
[Link]”,[Link]=FALSE)
[Link](tripdata_202406,”\\Users\\user\\Desktop\\1CaseStudy1v1\\
[Link]”,[Link]=FALSE)
[Link] (df,file='/Users/admin/new_file.csv')
[Link](tripdata_202406,file= /Users/user/Desktop/1CaseStudy1v1/
tripdata_202406.csv')
Example
df3 <- [Link](
id = c(10,11,12,13),
name = c('sai','ram','deepika','sahithi'),
gender = c('M','M',NA,'F'),
state = c('CA','NY',NA,NA)
)
View(df3)
name gender
id state
1 10 sai M CA
2 11 ram M NY
3 12 deepika NA NA
4 13 sahithi F NA
[Link](df3,file='/Users/user/Desktop/1CaseStudy1v1/[Link]')
[Link](tripdata_202405,file='/Users/user/Desktop/1CaseStudy1v1/tripdata_202405.csv')
[Link](diamonds,file='/Users/user/Desktop/1CaseStudy1v1/[Link]')
[Link](oneyear_trips_clean,file='/Users/user/Desktop/1CaseStudy1v1/
oneyear_trips_clean.csv')
P2.- Import dataset in excel (.csv) files to RStudio:
P2.1.- Dataset 202307 (Jul 2023)
tripdata_202307 <- read_csv("Desktop/1CaseStudy1v1/[Link]")
View(tripdata_202307) 7 Julio 2024 20:57
> tripdata_202307 <- read_csv("Desktop/1CaseStudy1v1/[Link]")
View(tripdata_202307) 7 Julio 2024 20:57
> tripdata_202307 <- read_csv("Desktop/1CaseStudy1v1/[Link]")
Rows: 767650 Columns: 13
── Column specification
──────────────────────────────────────────────────────────────────────────────
───────────
Delimiter: ","
chr (7): ride_id, rideable_type, start_station_name, start_station_id, end_station_name,
end_station_id, mem...
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.
> View(tripdata_202307)
start_stat start_stat end_station_n
ride_id rideable_type started_at ended_at end_station_id start_lat start_lng end_lat end_lng member_casual
ion_name ion_id ame
Kedzie A Public Rack -
9340B064F
1 0AEE130
electric_bike 2023-07-23 20:06:14 2023-07-23 20:22:44 ve & 110t 20204 Racine Ave & 877 41.69241 -87.70091 41.69483 -87.65304 member
h St 109th Pl
Western
D1460EE3 KA15040 Milwaukee Av
2 CE0D8AF8
classic_bike 2023-07-23 17:05:07 2023-07-23 17:18:37 Ave & W
00103 e & Grand Ave
13033 41.89842 -87.68660 41.89158 -87.64838 member
alton St
Western
DF41BE31 KA15040 Damen Ave & TA1305000
3 B895A25E
classic_bike 2023-07-23 10:14:53 2023-07-23 10:24:29 Ave & W
00103 Pierce Ave 041
41.89842 -87.68660 41.90940 -87.67769 member
alton St
Racine A
9624A2937 Clinton St & TA1305000
4 49EF703
electric_bike 2023-07-21 08:27:44 2023-07-21 08:32:40 ve & Ran 13155
Madison St 032
41.88411 -87.65694 41.88275 -87.64119 member
dolph St
Showing 1 to 9 of 767,650 entries, 13 total columns
10 primeras filas del dataset : “tripdata_202307”, presentación en Excel
P2.2.- Dataset 202308 (Agu 2023)
> tripdata_202308 <- read_csv("Desktop/1CaseStudy1v1/[Link]")
Rows: 771693 Columns: 13
── Column specification
──────────────────────────────────────────────────────────────────────────────
───────────
Delimiter: ","
chr (7): ride_id, rideable_type, start_station_name, start_station_id, end_station_name,
end_station_id, mem...
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.
> View(tripdata_202308)
10 primeras filas del dataset : “tripdata_202308”, presentación en Excel
P2.3.- Dataset 202309 (Sept 2023)
> tripdata_202309 <- read_csv("Desktop/1CaseStudy1v1/[Link]")
Rows: 666371 Columns: 13
── Column specification
──────────────────────────────────────────────────────────────────────────────
───────────
Delimiter: ","
chr (7): ride_id, rideable_type, start_station_name, start_station_id, end_station_name,
end_station_id, mem...
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.
> View(tripdata_202309)
10 primeras filas del dataset : “tripdata_202309”, presentación en Excel
P2.4.- Dataset 202310 (Oct 2023)
> tripdata_202310 <- read_csv("Desktop/1CaseStudy1v1/[Link]")
Rows: 537113 Columns: 13
── Column specification
──────────────────────────────────────────────────────────────────────────────
───────────
Delimiter: ","
chr (7): ride_id, rideable_type, start_station_name, start_station_id, end_station_name,
end_station_id, mem...
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.
> View(tripdata_202310)
TABLA 202310
P2.5.- Dataset 202311 (Nov 2023)
> tripdata_202311 <- read_csv("Desktop/1CaseStudy1v1/[Link]")
Rows: 362518 Columns: 13
── Column specification
──────────────────────────────────────────────────────────────────────────────
───────────
Delimiter: ","
chr (7): ride_id, rideable_type, start_station_name, start_station_id, end_station_name,
end_station_id, mem...
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.
> View(tripdata_202311)
TABLA 202311
P2.6.- Dataset 202312 (Dic 2023)
> tripdata_202312 <- read_csv("Desktop/1CaseStudy1v1/[Link]")
Rows: 224073 Columns: 13
── Column specification
──────────────────────────────────────────────────────────────────────────────
───────────
Delimiter: ","
chr (7): ride_id, rideable_type, start_station_name, start_station_id, end_station_name,
end_station_id, mem...
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.
> View(tripdata_202312)
TABLA 202311
P2.7.- Dataset 202401 (Jan 2024)
> tripdata_202401 <- read_csv("Desktop/1CaseStudy1v1/[Link]")
Rows: 144873 Columns: 13
── Column specification
──────────────────────────────────────────────────────────────────────────────
───────────
Delimiter: ","
chr (7): ride_id, rideable_type, start_station_name, start_station_id, end_station_name,
end_station_id, mem...
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.
> View(tripdata_202401)
TABLA 202401
P2.8.- Dataset 202402 (Feb 2024)
> tripdata_202402 <- read_csv("Desktop/1CaseStudy1v1/[Link]")
Rows: 223164 Columns: 13
── Column specification
──────────────────────────────────────────────────────────────────────────────
───────────
Delimiter: ","
chr (7): ride_id, rideable_type, start_station_name, start_station_id, end_station_name,
end_station_id, mem...
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.
> View(tripdata_202402)
TABLA 202402
P2.9.- Dataset 202403 (Mar 2024)
> tripdata_202403 <- read_csv("Desktop/1CaseStudy1v1/[Link]")
Rows: 301687 Columns: 13
── Column specification
──────────────────────────────────────────────────────────────────────────────
───────────
Delimiter: ","
chr (7): ride_id, rideable_type, start_station_name, start_station_id, end_station_name,
end_station_id, mem...
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.
> View(tripdata_202403)
TABLA
P2.9.- Dataset 202404 (Apr 2024)
> tripdata_202404 <- read_csv("Desktop/1CaseStudy1v1/[Link]")
Rows: 415025 Columns: 13
── Column specification
──────────────────────────────────────────────────────────────────────────────
───────────
Delimiter: ","
chr (7): ride_id, rideable_type, start_station_name, start_station_id, end_station_name,
end_station_id, mem...
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.
> View(tripdata_202404)
TABLA
P2.10.- Dataset 202405 (May 2024)
> tripdata_202405 <- read_csv("Desktop/1CaseStudy1v1/[Link]")
Rows: 609493 Columns: 13
── Column specification
──────────────────────────────────────────────────────────────────────────────
───────────
Delimiter: ","
chr (7): ride_id, rideable_type, start_station_name, start_station_id, end_station_name,
end_station_id, mem...
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.
> View(tripdata_202405)
TABLA 202405
P2.11.- Dataset 202406 (Jun 2024)
> tripdata_202406 <- read_csv("Desktop/1CaseStudy1v1/[Link]")
Rows: 716551 Columns: 13
── Column specification
──────────────────────────────────────────────────────────────────────────────
───────────
Delimiter: ","
chr (7): ride_id, rideable_type, start_station_name, start_station_id, end_station_name,
end_station_id, mem...
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.
> View(tripdata_202406)
TABLA 202406
P3.- Check column names of each dataset for consistency:
BM: Hacer en excel una tabla con los nombres de las columnas en “X” y el nombre del
mes de la data en eje “Y”. Para mostrar la “consistencia” de los nombres de las
colummas
> colnames(tripdata_202012)
[1] "ride_id" "rideable_type" "started_at" "ended_at"
[5] "start_station_name" "start_station_id" "end_station_name" "end_station_id"
[9] "start_lat" "start_lng" "end_lat" "end_lng"
[13] "member_casual"
P3.1- :
Dataset: tripdata_202307
> sapply(tripdata_202307,class)
$ride_id
[1] "character"
$rideable_type
[1] "character"
$started_at
[1] "POSIXct" "POSIXt"
$ended_at
[1] "POSIXct" "POSIXt"
$start_station_name
[1] "character"
$start_station_id
[1] "character"
$end_station_name
[1] "character"
$end_station_id
[1] "character"
$start_lat
[1] "numeric"
$start_lng
[1] "numeric"
$end_lat
[1] "numeric"
$end_lng
[1] "numeric"
$member_casual
[1] "character"
P3.2- :
Dataset: tripdata_202308
> sapply(tripdata_202308,class)
$ride_id
[1] "character"
$rideable_type
[1] "character"
$started_at
[1] "POSIXct" "POSIXt"
$ended_at
[1] "POSIXct" "POSIXt"
$start_station_name
[1] "character"
$start_station_id
[1] "character"
$end_station_name
[1] "character"
$end_station_id
[1] "character"
$start_lat
[1] "numeric"
$start_lng
[1] "numeric"
$end_lat
[1] "numeric"
$end_lng
[1] "numeric"
$member_casual
P3.3- :
> sapply(tripdata_202309,class)
$ride_id
[1] "character"
$rideable_type
[1] "character"
$started_at
[1] "POSIXct" "POSIXt"
$ended_at
[1] "POSIXct" "POSIXt"
$start_station_name
[1] "character"
$start_station_id
[1] "character"
$end_station_name
[1] "character"
$end_station_id
[1] "character"
$start_lat
[1] "numeric"
$start_lng
[1] "numeric"
$end_lat
[1] "numeric"
$end_lng
[1] "numeric"
$member_casual
[1] "character"
P3.4- :
> sapply(tripdata_202310,class)
$ride_id
[1] "character"
$rideable_type
[1] "character"
$started_at
[1] "POSIXct" "POSIXt"
$ended_at
[1] "POSIXct" "POSIXt"
$start_station_name
[1] "character"
$start_station_id
[1] "character"
$end_station_name
[1] "character"
$end_station_id
[1] "character"
$start_lat
[1] "numeric"
$start_lng
[1] "numeric"
$end_lat
[1] "numeric"
$end_lng
[1] "numeric"
$member_casual
[1] "character"
P3.5- :
> sapply(tripdata_202311,class)
$ride_id
[1] "character"
$rideable_type
[1] "character"
$started_at
[1] "POSIXct" "POSIXt"
$ended_at
[1] "POSIXct" "POSIXt"
$start_station_name
[1] "character"
$start_station_id
[1] "character"
$end_station_name
[1] "character"
$end_station_id
[1] "character"
$start_lat
[1] "numeric"
$start_lng
[1] "numeric"
$end_lat
[1] "numeric"
$end_lng
[1] "numeric"
$member_casual
[1] "character"
P3.6- :
> sapply(tripdata_202312,class)
$ride_id
[1] "character"
$rideable_type
[1] "character"
$started_at
[1] "POSIXct" "POSIXt"
$ended_at
[1] "POSIXct" "POSIXt"
$start_station_name
[1] "character"
$start_station_id
[1] "character"
$end_station_name
[1] "character"
$end_station_id
[1] "character"
$start_lat
[1] "numeric"
$start_lng
[1] "numeric"
$end_lat
[1] "numeric"
$end_lng
[1] "numeric"
$member_casual
[1] "character"
P3.7- :
> sapply(tripdata_202401,class)
$ride_id
[1] "character"
$rideable_type
[1] "character"
$started_at
[1] "POSIXct" "POSIXt"
$ended_at
[1] "POSIXct" "POSIXt"
$start_station_name
[1] "character"
$start_station_id
[1] "character"
$end_station_name
[1] "character"
$end_station_id
[1] "character"
$start_lat
[1] "numeric"
$start_lng
[1] "numeric"
$end_lat
[1] "numeric"
$end_lng
[1] "numeric"
$member_casual
[1] "character"
P3.8- :
> sapply(tripdata_202402,class)
$ride_id
[1] "character"
$rideable_type
[1] "character"
$started_at
[1] "POSIXct" "POSIXt"
$ended_at
[1] "POSIXct" "POSIXt"
$start_station_name
[1] "character"
$start_station_id
[1] "character"
$end_station_name
[1] "character"
$end_station_id
[1] "character"
$start_lat
[1] "numeric"
$start_lng
[1] "numeric"
$end_lat
[1] "numeric"
$end_lng
[1] "numeric"
$member_casual
[1] "character"
P3.9- :
> sapply(tripdata_202403,class)
$ride_id
[1] "character"
$rideable_type
[1] "character"
$started_at
[1] "POSIXct" "POSIXt"
$ended_at
[1] "POSIXct" "POSIXt"
$start_station_name
[1] "character"
$start_station_id
[1] "character"
$end_station_name
[1] "character"
$end_station_id
[1] "character"
$start_lat
[1] "numeric"
$start_lng
[1] "numeric"
$end_lat
[1] "numeric"
$end_lng
[1] "numeric"
$member_casual
[1] "character"
P3.10- :
> sapply(tripdata_202404,class)
$ride_id
[1] "character"
$rideable_type
[1] "character"
$started_at
[1] "POSIXct" "POSIXt"
$ended_at
[1] "POSIXct" "POSIXt"
$start_station_name
[1] "character"
$start_station_id
[1] "character"
$end_station_name
[1] "character"
$end_station_id
[1] "character"
$start_lat
[1] "numeric"
$start_lng
[1] "numeric"
$end_lat
[1] "numeric"
$end_lng
[1] "numeric"
$member_casual
[1] "character"
P3.11- :
> sapply(tripdata_202405,class)
$ride_id
[1] "character"
$rideable_type
[1] "character"
$started_at
[1] "POSIXct" "POSIXt"
$ended_at
[1] "POSIXct" "POSIXt"
$start_station_name
[1] "character"
$start_station_id
[1] "character"
$end_station_name
[1] "character"
$end_station_id
[1] "character"
$start_lat
[1] "numeric"
$start_lng
[1] "numeric"
$end_lat
[1] "numeric"
$end_lng
[1] "numeric"
$member_casual
[1] "character"
P3.12- :
> sapply(tripdata_202406,class)
$ride_id
[1] "character"
$rideable_type
[1] "character"
$started_at
[1] "POSIXct" "POSIXt"
$ended_at
[1] "POSIXct" "POSIXt"
$start_station_name
[1] "character"
$start_station_id
[1] "character"
$end_station_name
[1] "character"
$end_station_id
[1] "character"
$start_lat
[1] "numeric"
$start_lng
[1] "numeric"
$end_lat
[1] "numeric"
$end_lng
[1] "numeric"
$member_casual
[1] "character"
P4.- Check data structures and data types for all the data frames:
En lugar de usar > str(tripdata_202012)
ride_id = col_character(),
.. rideable_type = col_character(),
.. started_at = col_datetime(format = ""),
.. ended_at = col_datetime(format = ""),
.. start_station_name = col_character(),
.. start_station_id = col_character(),
.. end_station_name = col_character(),
.. end_station_id = col_character(),
.. start_lat = col_double(),
.. start_lng = col_double(),
.. end_lat = col_double(),
.. end_lng = col_double(),
.. member_casual = col_character()
Usar > sapply(tripdata_202307,class)
FUNCION PARA LEER LOS NOMBRES DE LAS COLUMNAS , Y EL TIPO DE VARIABLES
Syntax : ??
$ride_id. Name
[1] "character" Variable type
$rideable_type Name
[1] "character" Variable type
$started_at Name
[1] "POSIXct" "POSIXt" Variable type
Conclusion: All datasets (month by month) have the same data structures and data
types:
P5.- Combine all the datasets into one single data frame: oneyear_trips
BM:
Indicar Formato de bind_rows(ds1,ds2..ds12)
> all_trips <- bind_rows(tripdata_202012, tripdata_202101, tripdata_202102,
tripdata_202103, tripdata_202104, tripdata_202105, tripdata_202106, tripdata_202107,
tripdata_202108, tripdata_202109, tripdata_202110, tripdata_202111)
> View(all_trips)
VER ARCHIVO DE EXCEL ALL-TRIPS TIBBLE (DATA-ANALYTICS 8/1CASESTUDY/ ALL-TRIPS)
> oneyear_trips <- bind_rows(tripdata_202307, tripdata_202308, tripdata_202309,
tripdata_202310, tripdata_202311, tripdata_202312, tripdata_202401,tripdata_202402,
tripdata_202403, tripdata_202404, tripdata_202405, tripdata_202406)
> View(oneyear_trips)
[Showing 1 to 10 of 5,772,870 entries, 13 total columns]
El Dataset de los trips durante todo el año tiene 5.772.870 filas y 13 columnas
P6.-
1.-Replace all the null values to N/A for start_station id, start_station_name,
end_station_id and end_station_name columns, basado en inspeccion realizada en el
dataset de cada mes en Excel
Hay que eliminar muchas filas del dataset debido a que estas filas tienen sus campos en
blanco, como en el caso de start_station_id, end_station_name, end_station_id, los
cuales se pudieran recuperar a partir de sus valores de las coordenadas, en el caso que
esos valores estuviesen correctamente asentados en sus campos
2.-Eliminar columnas que no tienen en sus registros datos confiables, tales como :
start_lat, start_lng, end_lat y end_lng,
En el caso de: start_lat, start_lng, end_lat y end_lng, tienen sus campos con muy pocos
cantidad de decimales en sus valores(coordenadas) para determinar a que station
corresponden los campos en blanco mencionados en el punto 1, por lo tanto estas 4
columnas no aportan datos confiables y lo mas conveniente es eliminarlas.
Las coordenadas de cada Divvy Station se encuentran en el archivo
Divvy_Bicycle_Station_20240706.csv , suministrado por la operadora del Divvy Bicycle
Sharing System
Hay que eliminar muchas filas del dataset debido a que estas filas tienen sus campos en
blanco, como en el caso de start_station_id, end_station_name, end_station_id, los
cuales se pudieran recuperar a partir de sus valores de las coordenadas.y en el caso de:
start_lat, start_lng, end_lat y end_lng, tienen sus campos con muy pocos cantidad de
decimales en sus valores(coordenadas) para determinar a que station corresponden
los campos en blanco mencionados
BM:
> all_trips_forclean <- bind_rows(tripdata_202012, tripdata_202101, tripdata_202102,
tripdata_202103, tripdata_202104, tripdata_202105, tripdata_202106, tripdata_202107,
tripdata_202108, tripdata_202109, tripdata_202110, tripdata_202111)
> View(all_trips_forclean) [Showing 1 to 126 of 5,479,096 entries, 13 total columns]
VER ARCHIVO DE EXCEL all_trips_forclean TIBBLE = ALL-TRIPS TIBBLE (DATA-ANALYTICS
8/1CASESTUDY/ ALL-TRIPS TIBBLE) [Showing 1 to 126 of 5,479,096 entries, 13 total columns]
NOTA AMBOS ARCHIVOS SON IGUALES,.LO HICE CON ESE OTRO NOMBRE PARA LUEGO
ELIMINAR LOS NA CON [Link](), no fuese a cambiar la estructura del archivo original, lo cual
no pasó pues se transfirió es cambio a otro archivo all_trips_clean
> all_tripdata_clean <- drop_na(all_trips_forclean)
> View(all_tripdata_clean)
VER ARCHIVO DE EXCEL all_tripdata_clean (DATA-ANALYTICS 8/1CASESTUDY/
all_tripdata_clean) [Showing 1 to 14 of 4,525,842 entries, 13 total columns]
> all_tripdata_clean <- drop_na(all_trips). Script a usar
> View(all_tripdata_clean)
oneyear_trips_clean <- drop_na(oneyear_trips)
[Showing 1 to 10 of 4,369,277 entries, 13 total columns].
Se han eliminado 5,772,870 - 4,369,277 = 1,403,593 filas
Lo cual corresponde al 24,31% del dataset original, que gran parte de ellas se hubiesen
podido recuperar , en caso de que las coordenadas de las stations estuviesen apropidamente
asentadas en sus respectivos campos
P7.- Convert started_at and ended_at from char datatype to datetime datatype: