SlideShare a Scribd company logo
Uber_Trips_Visualizations.R
aymansiraj
Mon Aug 15 10:28:32 2016
# load required packages
suppressMessages(library(ggplot2))
suppressMessages(library(data.table))
suppressMessages(library(lubridate))
suppressMessages(library(scales))
suppressMessages(library(stringr))
suppressMessages(library(zoo))
suppressMessages(library(dplyr))
# load file and clean
setwd("/Users/aymansiraj/Google Drive/ix 2016 /RUber")
Uber <- read.csv("trip-history.csv")
Uber$trip_id <- NULL
Uber$date_time <- NULL
Uber$driver <- NULL
Uber$payment_method <- NULL
Uber$start_address <- NULL
Uber$end_address <- NULL
Uber <- Uber %>% subset(price != "")
# format data types currently
Uber$date <- as.character(Uber$date)
Uber$datenew <- parse_date_time(Uber$date, c('mdy'))
Uber$Month <- months(Uber$datenew)
Uber$Year <- year(Uber$datenew)
# create new columns to plot graphs
Uber$MonthYear = as.factor(paste(Uber$Month, Uber$Year, sep="-"))
Uber$currency<- as.factor(gsub("[0-9.]","", Uber$price))
Uber$pricenew <- as.numeric(gsub("[^0-9.]","", Uber$price))
# calculate amount spent on each currency
costpercurrency <- Uber %>%
group_by(currency) %>%
summarise(TotalCost = sum(pricenew))
# ggplot
city <- qplot(city, data=Uber, geom="bar", fill= car_type)
city + theme(axis.text.x = element_text(angle = 90, hjust = 1))
cartype <- qplot(car_type, data = Uber, geom = "bar", fill = city)
cartype + theme(axis.text.x = element_text(angle = 90, hjust = 1))
ggplot(Uber, aes(MonthYear)) + geom_bar() +
geom_text(stat='count',aes(label=..count..),vjust=-1) +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
costplot <- ggplot(costpercurrency, aes(x=currency, y=TotalCost)) +
geom_bar(stat="identity", fill="#FF9999", colour="black")
costplot + geom_text(aes(label=TotalCost), vjust=1.6, color="white",
size=3.5)
Uber_Trips_Visualizations

More Related Content

What's hot

Blog Hacks 2011
Blog Hacks 2011Blog Hacks 2011
Blog Hacks 2011
Yusuke Wada
 
FRP and Bacon.js
FRP and Bacon.jsFRP and Bacon.js
FRP and Bacon.js
Starbuildr
 
Wat.tf - Nati Cohen - DevOpsDays Tel Aviv 2018
Wat.tf - Nati Cohen - DevOpsDays Tel Aviv 2018Wat.tf - Nati Cohen - DevOpsDays Tel Aviv 2018
Wat.tf - Nati Cohen - DevOpsDays Tel Aviv 2018
DevOpsDays Tel Aviv
 
A Self Replicating Serverless Function
A Self Replicating Serverless FunctionA Self Replicating Serverless Function
A Self Replicating Serverless Function
Michael Adda
 
Starting out with Ember.js
Starting out with Ember.jsStarting out with Ember.js
Starting out with Ember.js
Anirudh Shivanand
 
Twib in Yokoahma.pm 2010/3/5
Twib in Yokoahma.pm 2010/3/5Twib in Yokoahma.pm 2010/3/5
Twib in Yokoahma.pm 2010/3/5
Yusuke Wada
 
WordPress 次期バージョンと日本のコミュニティ
WordPress 次期バージョンと日本のコミュニティWordPress 次期バージョンと日本のコミュニティ
WordPress 次期バージョンと日本のコミュニティ
Yuriko IKEDA
 
global_shopping_online
global_shopping_onlineglobal_shopping_online
global_shopping_online
drocallaghan
 
global_shopping_online
global_shopping_onlineglobal_shopping_online
global_shopping_online
drocallaghan
 
global_shopping_online
global_shopping_onlineglobal_shopping_online
global_shopping_online
drocallaghan
 
global_shopping_online
global_shopping_onlineglobal_shopping_online
global_shopping_online
drocallaghan
 
global_shopping_online
global_shopping_onlineglobal_shopping_online
global_shopping_online
drocallaghan
 
Up.Php
Up.PhpUp.Php
Up.Php
wsoom
 
第4回 g* ワークショップ はじめてみよう! Grailsプラグイン
第4回 g* ワークショップ はじめてみよう! Grailsプラグイン第4回 g* ワークショップ はじめてみよう! Grailsプラグイン
第4回 g* ワークショップ はじめてみよう! Grailsプラグイン
Tsuyoshi Yamamoto
 
Desymfony 2011 - Habemus Bundles
Desymfony 2011 - Habemus BundlesDesymfony 2011 - Habemus Bundles
Desymfony 2011 - Habemus Bundles
Albert Jessurum
 
Gaelyk
GaelykGaelyk
Mongo db modifiers
Mongo db modifiersMongo db modifiers
Mongo db modifiers
zarigatongy
 
Climbing out from the digital mud with unikernels / Ian Eyberg (DeferPanic)
Climbing out from the digital mud with unikernels / Ian Eyberg (DeferPanic)Climbing out from the digital mud with unikernels / Ian Eyberg (DeferPanic)
Climbing out from the digital mud with unikernels / Ian Eyberg (DeferPanic)
Ontico
 
Iron Blogger Hamburg #bchh13
Iron Blogger Hamburg #bchh13Iron Blogger Hamburg #bchh13
Iron Blogger Hamburg #bchh13
Kathrin Kaufmann
 
Java & Script ─ 清羽
Java & Script ─ 清羽Java & Script ─ 清羽
Java & Script ─ 清羽
taobao.com
 

What's hot (20)

Blog Hacks 2011
Blog Hacks 2011Blog Hacks 2011
Blog Hacks 2011
 
FRP and Bacon.js
FRP and Bacon.jsFRP and Bacon.js
FRP and Bacon.js
 
Wat.tf - Nati Cohen - DevOpsDays Tel Aviv 2018
Wat.tf - Nati Cohen - DevOpsDays Tel Aviv 2018Wat.tf - Nati Cohen - DevOpsDays Tel Aviv 2018
Wat.tf - Nati Cohen - DevOpsDays Tel Aviv 2018
 
A Self Replicating Serverless Function
A Self Replicating Serverless FunctionA Self Replicating Serverless Function
A Self Replicating Serverless Function
 
Starting out with Ember.js
Starting out with Ember.jsStarting out with Ember.js
Starting out with Ember.js
 
Twib in Yokoahma.pm 2010/3/5
Twib in Yokoahma.pm 2010/3/5Twib in Yokoahma.pm 2010/3/5
Twib in Yokoahma.pm 2010/3/5
 
WordPress 次期バージョンと日本のコミュニティ
WordPress 次期バージョンと日本のコミュニティWordPress 次期バージョンと日本のコミュニティ
WordPress 次期バージョンと日本のコミュニティ
 
global_shopping_online
global_shopping_onlineglobal_shopping_online
global_shopping_online
 
global_shopping_online
global_shopping_onlineglobal_shopping_online
global_shopping_online
 
global_shopping_online
global_shopping_onlineglobal_shopping_online
global_shopping_online
 
global_shopping_online
global_shopping_onlineglobal_shopping_online
global_shopping_online
 
global_shopping_online
global_shopping_onlineglobal_shopping_online
global_shopping_online
 
Up.Php
Up.PhpUp.Php
Up.Php
 
第4回 g* ワークショップ はじめてみよう! Grailsプラグイン
第4回 g* ワークショップ はじめてみよう! Grailsプラグイン第4回 g* ワークショップ はじめてみよう! Grailsプラグイン
第4回 g* ワークショップ はじめてみよう! Grailsプラグイン
 
Desymfony 2011 - Habemus Bundles
Desymfony 2011 - Habemus BundlesDesymfony 2011 - Habemus Bundles
Desymfony 2011 - Habemus Bundles
 
Gaelyk
GaelykGaelyk
Gaelyk
 
Mongo db modifiers
Mongo db modifiersMongo db modifiers
Mongo db modifiers
 
Climbing out from the digital mud with unikernels / Ian Eyberg (DeferPanic)
Climbing out from the digital mud with unikernels / Ian Eyberg (DeferPanic)Climbing out from the digital mud with unikernels / Ian Eyberg (DeferPanic)
Climbing out from the digital mud with unikernels / Ian Eyberg (DeferPanic)
 
Iron Blogger Hamburg #bchh13
Iron Blogger Hamburg #bchh13Iron Blogger Hamburg #bchh13
Iron Blogger Hamburg #bchh13
 
Java & Script ─ 清羽
Java & Script ─ 清羽Java & Script ─ 清羽
Java & Script ─ 清羽
 

Similar to Uber_Trips_Visualizations

dplyr
dplyrdplyr
Using R for Building a Simple and Effective Dashboard
Using R for Building a Simple and Effective DashboardUsing R for Building a Simple and Effective Dashboard
Using R for Building a Simple and Effective Dashboard
Andrea Gigli
 
Spark + Clojure for Topic Discovery - Zalando Tech Clojure/Conj Talk
Spark + Clojure for Topic Discovery - Zalando Tech Clojure/Conj TalkSpark + Clojure for Topic Discovery - Zalando Tech Clojure/Conj Talk
Spark + Clojure for Topic Discovery - Zalando Tech Clojure/Conj Talk
Zalando Technology
 
Юрий Буянов «Squeryl — ORM с человеческим лицом»
Юрий Буянов «Squeryl — ORM с человеческим лицом»Юрий Буянов «Squeryl — ORM с человеческим лицом»
Юрий Буянов «Squeryl — ORM с человеческим лицом»
e-Legion
 
API Development and Scala @ SoundCloud
API Development and Scala @ SoundCloudAPI Development and Scala @ SoundCloud
API Development and Scala @ SoundCloud
Bora Tunca
 
Bag Of Tricks From Iusethis
Bag Of Tricks From IusethisBag Of Tricks From Iusethis
Bag Of Tricks From Iusethis
Marcus Ramberg
 
R (Shiny Package) - Server Side Code for Decision Support System
R (Shiny Package) - Server Side Code for Decision Support SystemR (Shiny Package) - Server Side Code for Decision Support System
R (Shiny Package) - Server Side Code for Decision Support System
Maithreya Chakravarthula
 
Memory Manglement in Raku
Memory Manglement in RakuMemory Manglement in Raku
Memory Manglement in Raku
Workhorse Computing
 
JQuery Flot
JQuery FlotJQuery Flot
JQuery Flot
Arshavski Alexander
 
Postman On Steroids
Postman On SteroidsPostman On Steroids
Postman On Steroids
Sara Tornincasa
 
The never changing face of immutability
The never changing face of immutabilityThe never changing face of immutability
The never changing face of immutability
Chris Howe-Jones
 
Kafka Streams: Revisiting the decisions of the past (How I could have made it...
Kafka Streams: Revisiting the decisions of the past (How I could have made it...Kafka Streams: Revisiting the decisions of the past (How I could have made it...
Kafka Streams: Revisiting the decisions of the past (How I could have made it...
confluent
 
mongoDB @ banksalad
mongoDB @ banksaladmongoDB @ banksalad
mongoDB @ banksalad
Sunghoon Kang
 
I really need help with this assignment it is multiple parts# Part.pdf
I really need help with this assignment it is multiple parts# Part.pdfI really need help with this assignment it is multiple parts# Part.pdf
I really need help with this assignment it is multiple parts# Part.pdf
illyasraja7
 
Failsafe Mechanism for Yahoo Homepage
Failsafe Mechanism for Yahoo HomepageFailsafe Mechanism for Yahoo Homepage
Failsafe Mechanism for Yahoo Homepage
Kit Chan
 
Automation in angular js
Automation in angular jsAutomation in angular js
Automation in angular js
Marcin Wosinek
 
dplyr use case
dplyr use casedplyr use case
dplyr use case
Romain Francois
 
OpenStreetMap R
OpenStreetMap ROpenStreetMap R
OpenStreetMap R
TanayDeshmukh4
 
Velocity tips and tricks
Velocity tips and tricksVelocity tips and tricks
Velocity tips and tricks
dotCMS
 
Large Scale Data Processing & Storage
Large Scale Data Processing & StorageLarge Scale Data Processing & Storage
Large Scale Data Processing & Storage
Ilayaraja P
 

Similar to Uber_Trips_Visualizations (20)

dplyr
dplyrdplyr
dplyr
 
Using R for Building a Simple and Effective Dashboard
Using R for Building a Simple and Effective DashboardUsing R for Building a Simple and Effective Dashboard
Using R for Building a Simple and Effective Dashboard
 
Spark + Clojure for Topic Discovery - Zalando Tech Clojure/Conj Talk
Spark + Clojure for Topic Discovery - Zalando Tech Clojure/Conj TalkSpark + Clojure for Topic Discovery - Zalando Tech Clojure/Conj Talk
Spark + Clojure for Topic Discovery - Zalando Tech Clojure/Conj Talk
 
Юрий Буянов «Squeryl — ORM с человеческим лицом»
Юрий Буянов «Squeryl — ORM с человеческим лицом»Юрий Буянов «Squeryl — ORM с человеческим лицом»
Юрий Буянов «Squeryl — ORM с человеческим лицом»
 
API Development and Scala @ SoundCloud
API Development and Scala @ SoundCloudAPI Development and Scala @ SoundCloud
API Development and Scala @ SoundCloud
 
Bag Of Tricks From Iusethis
Bag Of Tricks From IusethisBag Of Tricks From Iusethis
Bag Of Tricks From Iusethis
 
R (Shiny Package) - Server Side Code for Decision Support System
R (Shiny Package) - Server Side Code for Decision Support SystemR (Shiny Package) - Server Side Code for Decision Support System
R (Shiny Package) - Server Side Code for Decision Support System
 
Memory Manglement in Raku
Memory Manglement in RakuMemory Manglement in Raku
Memory Manglement in Raku
 
JQuery Flot
JQuery FlotJQuery Flot
JQuery Flot
 
Postman On Steroids
Postman On SteroidsPostman On Steroids
Postman On Steroids
 
The never changing face of immutability
The never changing face of immutabilityThe never changing face of immutability
The never changing face of immutability
 
Kafka Streams: Revisiting the decisions of the past (How I could have made it...
Kafka Streams: Revisiting the decisions of the past (How I could have made it...Kafka Streams: Revisiting the decisions of the past (How I could have made it...
Kafka Streams: Revisiting the decisions of the past (How I could have made it...
 
mongoDB @ banksalad
mongoDB @ banksaladmongoDB @ banksalad
mongoDB @ banksalad
 
I really need help with this assignment it is multiple parts# Part.pdf
I really need help with this assignment it is multiple parts# Part.pdfI really need help with this assignment it is multiple parts# Part.pdf
I really need help with this assignment it is multiple parts# Part.pdf
 
Failsafe Mechanism for Yahoo Homepage
Failsafe Mechanism for Yahoo HomepageFailsafe Mechanism for Yahoo Homepage
Failsafe Mechanism for Yahoo Homepage
 
Automation in angular js
Automation in angular jsAutomation in angular js
Automation in angular js
 
dplyr use case
dplyr use casedplyr use case
dplyr use case
 
OpenStreetMap R
OpenStreetMap ROpenStreetMap R
OpenStreetMap R
 
Velocity tips and tricks
Velocity tips and tricksVelocity tips and tricks
Velocity tips and tricks
 
Large Scale Data Processing & Storage
Large Scale Data Processing & StorageLarge Scale Data Processing & Storage
Large Scale Data Processing & Storage
 

Uber_Trips_Visualizations

  • 1. Uber_Trips_Visualizations.R aymansiraj Mon Aug 15 10:28:32 2016 # load required packages suppressMessages(library(ggplot2)) suppressMessages(library(data.table)) suppressMessages(library(lubridate)) suppressMessages(library(scales)) suppressMessages(library(stringr)) suppressMessages(library(zoo)) suppressMessages(library(dplyr)) # load file and clean setwd("/Users/aymansiraj/Google Drive/ix 2016 /RUber") Uber <- read.csv("trip-history.csv") Uber$trip_id <- NULL Uber$date_time <- NULL Uber$driver <- NULL Uber$payment_method <- NULL Uber$start_address <- NULL Uber$end_address <- NULL Uber <- Uber %>% subset(price != "") # format data types currently Uber$date <- as.character(Uber$date) Uber$datenew <- parse_date_time(Uber$date, c('mdy')) Uber$Month <- months(Uber$datenew) Uber$Year <- year(Uber$datenew) # create new columns to plot graphs Uber$MonthYear = as.factor(paste(Uber$Month, Uber$Year, sep="-")) Uber$currency<- as.factor(gsub("[0-9.]","", Uber$price)) Uber$pricenew <- as.numeric(gsub("[^0-9.]","", Uber$price)) # calculate amount spent on each currency costpercurrency <- Uber %>% group_by(currency) %>% summarise(TotalCost = sum(pricenew))
  • 2. # ggplot city <- qplot(city, data=Uber, geom="bar", fill= car_type) city + theme(axis.text.x = element_text(angle = 90, hjust = 1)) cartype <- qplot(car_type, data = Uber, geom = "bar", fill = city) cartype + theme(axis.text.x = element_text(angle = 90, hjust = 1))
  • 3. ggplot(Uber, aes(MonthYear)) + geom_bar() + geom_text(stat='count',aes(label=..count..),vjust=-1) + theme(axis.text.x = element_text(angle = 90, hjust = 1))
  • 4. costplot <- ggplot(costpercurrency, aes(x=currency, y=TotalCost)) + geom_bar(stat="identity", fill="#FF9999", colour="black") costplot + geom_text(aes(label=TotalCost), vjust=1.6, color="white", size=3.5)