SlideShare ist ein Scribd-Unternehmen logo
1 von 5
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

Weitere ähnliche Inhalte

Was ist angesagt?

FRP and Bacon.js
FRP and Bacon.jsFRP and Bacon.js
FRP and Bacon.jsStarbuildr
 
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 2018DevOpsDays Tel Aviv
 
A Self Replicating Serverless Function
A Self Replicating Serverless FunctionA Self Replicating Serverless Function
A Self Replicating Serverless FunctionMichael Adda
 
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/5Yusuke Wada
 
WordPress 次期バージョンと日本のコミュニティ
WordPress 次期バージョンと日本のコミュニティWordPress 次期バージョンと日本のコミュニティ
WordPress 次期バージョンと日本のコミュニティYuriko IKEDA
 
global_shopping_online
global_shopping_onlineglobal_shopping_online
global_shopping_onlinedrocallaghan
 
global_shopping_online
global_shopping_onlineglobal_shopping_online
global_shopping_onlinedrocallaghan
 
global_shopping_online
global_shopping_onlineglobal_shopping_online
global_shopping_onlinedrocallaghan
 
global_shopping_online
global_shopping_onlineglobal_shopping_online
global_shopping_onlinedrocallaghan
 
global_shopping_online
global_shopping_onlineglobal_shopping_online
global_shopping_onlinedrocallaghan
 
Up.Php
Up.PhpUp.Php
Up.Phpwsoom
 
第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 BundlesAlbert Jessurum
 
Mongo db modifiers
Mongo db modifiersMongo db modifiers
Mongo db modifierszarigatongy
 
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 #bchh13Kathrin Kaufmann
 
Java & Script ─ 清羽
Java & Script ─ 清羽Java & Script ─ 清羽
Java & Script ─ 清羽taobao.com
 

Was ist angesagt? (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 ─ 清羽
 

Ähnlich wie Uber_Trips_Visualizations

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 DashboardAndrea 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 TalkZalando 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 @ SoundCloudBora Tunca
 
Bag Of Tricks From Iusethis
Bag Of Tricks From IusethisBag Of Tricks From Iusethis
Bag Of Tricks From IusethisMarcus 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 SystemMaithreya Chakravarthula
 
The never changing face of immutability
The never changing face of immutabilityThe never changing face of immutability
The never changing face of immutabilityChris 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
 
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.pdfillyasraja7
 
Failsafe Mechanism for Yahoo Homepage
Failsafe Mechanism for Yahoo HomepageFailsafe Mechanism for Yahoo Homepage
Failsafe Mechanism for Yahoo HomepageKit Chan
 
Automation in angular js
Automation in angular jsAutomation in angular js
Automation in angular jsMarcin Wosinek
 
Velocity tips and tricks
Velocity tips and tricksVelocity tips and tricks
Velocity tips and tricksdotCMS
 
Large Scale Data Processing & Storage
Large Scale Data Processing & StorageLarge Scale Data Processing & Storage
Large Scale Data Processing & StorageIlayaraja P
 

Ähnlich wie 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)