SlideShare a Scribd company logo
Trading volume mapping
in recent environment
Global Tokyo. 1
@teramonagi
Motivation of this Talk
• is rapidly evolving in recent years.
• Greate packages are appearing one after
another!!!
• Needless to say, googleVis too
• Let me show how to use these for data
analysis in this presentation
1. Data manipulation by dplyr
2. Visualization by rMaps
2
Libraries to be needed
3
library(data.table)
library(rMaps)
library(dplyr)
library(magrittr)
library(countrycode)
library(xts)
library(pings)
4
I forgot to use googleVis
Sorry!!!
5
Before we get on
the main subject
Fantastic collaboration -dplyr, magrittr, pings-
• You can chain commands with
forward-pipe operator %>%
(magrittr)
• Data manipulation like “mutate”,
“group_by”, “summarize” (dplyr)
• Soundlize(?) data manipulation
(pings)
6
Fantastic collaboration -dplyr, magrittr, pings-
• Install and load packages
7
library(devtools)
install_github(“dichika/pings”)
install.packages(c(“dplyr”, “magrittr”))
library(pings)
library(dplyr)
library(magrittr)
You can write like this(dplyr+magritter):
8
iris %>%
#add new column “width”
mutate(Width=Sepal.Width+Petal.Width) %>%
#grouping data by species
group_by(Species) %>%
#calculate mean value of Width column
summarize(AverageWidth=mean(Width)) %>%
#Extract only the column “AverageWidth”
use_series(AverageWidth) %>%
#Dvide AverageWidth value by 3
divide_by(3) %>%
#Get the maximum value of AverageWidth/3
max
You can write like this(dplyr+magritter+pings):
9
pings(iris %>%
#add new column “width”
mutate(Width=Sepal.Width+Petal.Width) %>%
#grouping data by species
group_by(Species) %>%
#calculate mean value of Width column
summarize(AverageWidth=mean(Width)) %>%
#Extract only the column “AverageWidth”
use_series(AverageWidth) %>%
#Dvide AverageWidth value by 3
divide_by(3) %>%
#Get the maximum value of AverageWidth/3
max)
10
You will be hooked on this sound
11
Get back to
the main subject
Data for analysis….
• I prepared trading volume data
• It is already formed
• I used “data.table” package which
gives us the function to fast speed
data loading(fread function)
12
Data for analysis…
13
> str(x)
Classes ‘data.table’ and 'data.frame':
21245 obs. of 5 variables:
$ Date : Date, format: "2012-11-01" "2012-11-
01" ...
$ User_Country: chr "AR" "AT" "AU" "BD" ...
$ Amount : num 775582 931593 565871 566 7986 ...
$ ISO3C : chr "ARG" "AUT" "AUS" "BGD" ...
$ Date2 : num 15645 15645 15645 15645 15645 ...
- attr(*, ".internal.selfref")=
> head(x)
Date User_Country Amount ISO3C Date2
1 2012-11-01 AR 775581.543 ARG 15645
2 2012-11-01 AT 931592.986 AUT 15645
3 2012-11-01 AU 565870.994 AUS 15645
4 2012-11-01 BD 565.863 BGD 15645
5 2012-11-01 BE 7985.860 BEL 15645
6 2012-11-01 BG 56863.958 BGR 15645
Data processing by dplyr
14
> xs <- x %>%
+ mutate(YearMonth=as.yearmon(Date)) %>%
+ group_by(YearMonth, ISO3C) %>%
+ summarize(Amount=floor(sum(Amount)/10^4))
> head(xs)
YearMonth ISO3C Amount
1 11 2012 ALB 0
2 11 2012 ARE 7
3 11 2012 ARG 647
4 11 2012 AUS 2153
5 11 2012 AUT 503
6 11 2012 BEL 41
Data processing by dplyr
15
> xs <- xs %>%
+ tally %>%
+ select(YearMonth) %>%
+ mutate(Counter=row_number(YearMonth)) %>%
+ inner_join(y=xs)
> head(xs)
YearMonth Counter ISO3C Amount
1 11 2012 1 ALB 0
2 11 2012 1 ARE 7
3 11 2012 1 ARG 647
4 11 2012 1 AUS 2153
Data processing by dplyr
• Define some variables we use later
16
> min.date <- xs %>%
+ use_series(YearMonth) %>%
+ as.Date %>% min %>% as.character
> max.counter <- xs %>%
+ use_series(Counter) %>% max
> min.date
[1] "2012-11-01"
> max.counter
[1] 12
Visualize with rMaps
• Install and load rMaps
17
library(devtools)
install_github('ramnathv/rCharts@dev')
install_github('ramnathv/rMaps')
library(rMaps)
Visualize with rMaps
• Easy to visualize yearly data
• But, we have monthly data
• We need to customize template
HTML and javascript code
• Little bit long code…
18
Visualize with rMaps
19
d <- ichoropleth(log(Amount) ~ ISO3C, data=as.data.frame(xs), animate="Counter", map="world")
d$setTemplate(chartDiv = sprintf("
<div class='container'>
<button ng-click='animateMap()'>Play</button>
<span ng-bind='date_show'></span>
<div id='{{chartId}}' class='rChart datamaps'></div>
</div>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'></script>
<script src='http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js'></script>
<script>
function rChartsCtrl($scope, $timeout){
$scope.counter = 1;
$scope.date = new Date('%s');
$scope.date_show = $.datepicker.formatDate('yy-mm', $scope.date);
$scope.animateMap = function(){
if ($scope.counter > %s){
return;
}
map{{chartId}}.updateChoropleth(chartParams.newData[$scope.counter]);
$scope.counter += 1;
$scope.date.setMonth($scope.date.getMonth()+1);
$scope.date_show = $.datepicker.formatDate('yy-mm', $scope.date);
$timeout($scope.animateMap, 1000)
}
}
</script>", min.date, max.counter)
)
d
Visualize with rMaps
20
All Codes in this presentation:
21
github.com/teramonagi/GlobalTokyoR1
Enjoy!!!
22

More Related Content

What's hot

Sea Amsterdam 2014 November 19
Sea Amsterdam 2014 November 19Sea Amsterdam 2014 November 19
Sea Amsterdam 2014 November 19
GoDataDriven
 
Google Cloud Storage backup and archive
Google Cloud Storage backup and archiveGoogle Cloud Storage backup and archive
Google Cloud Storage backup and archive
Ido Green
 
ClickHouse Introduction by Alexander Zaitsev, Altinity CTO
ClickHouse Introduction by Alexander Zaitsev, Altinity CTOClickHouse Introduction by Alexander Zaitsev, Altinity CTO
ClickHouse Introduction by Alexander Zaitsev, Altinity CTO
Altinity Ltd
 
Obtaining the Perfect Smoke By Monitoring Your BBQ with InfluxDB and Telegraf
Obtaining the Perfect Smoke By Monitoring Your BBQ with InfluxDB and TelegrafObtaining the Perfect Smoke By Monitoring Your BBQ with InfluxDB and Telegraf
Obtaining the Perfect Smoke By Monitoring Your BBQ with InfluxDB and Telegraf
InfluxData
 
BigQueryで作る分析環境
BigQueryで作る分析環境BigQueryで作る分析環境
BigQueryで作る分析環境
将央 山口
 
Data analytics with hadoop hive on multiple data centers
Data analytics with hadoop hive on multiple data centersData analytics with hadoop hive on multiple data centers
Data analytics with hadoop hive on multiple data centersHirotaka Niisato
 
RDO hangout on gnocchi
RDO hangout on gnocchiRDO hangout on gnocchi
RDO hangout on gnocchi
Eoghan Glynn
 
Analyzing Larger RasterData in a Jupyter Notebook with GeoPySpark on AWS - FO...
Analyzing Larger RasterData in a Jupyter Notebook with GeoPySpark on AWS - FO...Analyzing Larger RasterData in a Jupyter Notebook with GeoPySpark on AWS - FO...
Analyzing Larger RasterData in a Jupyter Notebook with GeoPySpark on AWS - FO...
Rob Emanuele
 
codecentric AG: Using Cassandra and Clojure for Data Crunching backends
codecentric AG: Using Cassandra and Clojure for Data Crunching backendscodecentric AG: Using Cassandra and Clojure for Data Crunching backends
codecentric AG: Using Cassandra and Clojure for Data Crunching backends
DataStax Academy
 
Weather of the Century: Visualization
Weather of the Century: VisualizationWeather of the Century: Visualization
Weather of the Century: Visualization
MongoDB
 
Taming the Tiger: Tips and Tricks for Using Telegraf
Taming the Tiger: Tips and Tricks for Using TelegrafTaming the Tiger: Tips and Tricks for Using Telegraf
Taming the Tiger: Tips and Tricks for Using Telegraf
InfluxData
 
Around the world with extensions | PostgreSQL Conference Europe 2018 | Craig ...
Around the world with extensions | PostgreSQL Conference Europe 2018 | Craig ...Around the world with extensions | PostgreSQL Conference Europe 2018 | Craig ...
Around the world with extensions | PostgreSQL Conference Europe 2018 | Craig ...
Citus Data
 
Climate data in r with the raster package
Climate data in r with the raster packageClimate data in r with the raster package
Climate data in r with the raster packageAlberto Labarga
 
Big Data Day LA 2015 - Large Scale Distinct Count -- The HyperLogLog algorith...
Big Data Day LA 2015 - Large Scale Distinct Count -- The HyperLogLog algorith...Big Data Day LA 2015 - Large Scale Distinct Count -- The HyperLogLog algorith...
Big Data Day LA 2015 - Large Scale Distinct Count -- The HyperLogLog algorith...
Data Con LA
 
Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...
Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...
Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...
InfluxData
 
HyperLogLog in Hive - How to count sheep efficiently?
HyperLogLog in Hive - How to count sheep efficiently?HyperLogLog in Hive - How to count sheep efficiently?
HyperLogLog in Hive - How to count sheep efficiently?
bzamecnik
 
Collecting metrics with Graphite and StatsD
Collecting metrics with Graphite and StatsDCollecting metrics with Graphite and StatsD
Collecting metrics with Graphite and StatsD
itnig
 
The Weather of the Century
The Weather of the CenturyThe Weather of the Century
The Weather of the Century
MongoDB
 
Supercharge your Analytics with ClickHouse, v.2. By Vadim Tkachenko
Supercharge your Analytics with ClickHouse, v.2. By Vadim TkachenkoSupercharge your Analytics with ClickHouse, v.2. By Vadim Tkachenko
Supercharge your Analytics with ClickHouse, v.2. By Vadim Tkachenko
Altinity Ltd
 
The Weather of the Century Part 3: Visualization
The Weather of the Century Part 3: VisualizationThe Weather of the Century Part 3: Visualization
The Weather of the Century Part 3: Visualization
MongoDB
 

What's hot (20)

Sea Amsterdam 2014 November 19
Sea Amsterdam 2014 November 19Sea Amsterdam 2014 November 19
Sea Amsterdam 2014 November 19
 
Google Cloud Storage backup and archive
Google Cloud Storage backup and archiveGoogle Cloud Storage backup and archive
Google Cloud Storage backup and archive
 
ClickHouse Introduction by Alexander Zaitsev, Altinity CTO
ClickHouse Introduction by Alexander Zaitsev, Altinity CTOClickHouse Introduction by Alexander Zaitsev, Altinity CTO
ClickHouse Introduction by Alexander Zaitsev, Altinity CTO
 
Obtaining the Perfect Smoke By Monitoring Your BBQ with InfluxDB and Telegraf
Obtaining the Perfect Smoke By Monitoring Your BBQ with InfluxDB and TelegrafObtaining the Perfect Smoke By Monitoring Your BBQ with InfluxDB and Telegraf
Obtaining the Perfect Smoke By Monitoring Your BBQ with InfluxDB and Telegraf
 
BigQueryで作る分析環境
BigQueryで作る分析環境BigQueryで作る分析環境
BigQueryで作る分析環境
 
Data analytics with hadoop hive on multiple data centers
Data analytics with hadoop hive on multiple data centersData analytics with hadoop hive on multiple data centers
Data analytics with hadoop hive on multiple data centers
 
RDO hangout on gnocchi
RDO hangout on gnocchiRDO hangout on gnocchi
RDO hangout on gnocchi
 
Analyzing Larger RasterData in a Jupyter Notebook with GeoPySpark on AWS - FO...
Analyzing Larger RasterData in a Jupyter Notebook with GeoPySpark on AWS - FO...Analyzing Larger RasterData in a Jupyter Notebook with GeoPySpark on AWS - FO...
Analyzing Larger RasterData in a Jupyter Notebook with GeoPySpark on AWS - FO...
 
codecentric AG: Using Cassandra and Clojure for Data Crunching backends
codecentric AG: Using Cassandra and Clojure for Data Crunching backendscodecentric AG: Using Cassandra and Clojure for Data Crunching backends
codecentric AG: Using Cassandra and Clojure for Data Crunching backends
 
Weather of the Century: Visualization
Weather of the Century: VisualizationWeather of the Century: Visualization
Weather of the Century: Visualization
 
Taming the Tiger: Tips and Tricks for Using Telegraf
Taming the Tiger: Tips and Tricks for Using TelegrafTaming the Tiger: Tips and Tricks for Using Telegraf
Taming the Tiger: Tips and Tricks for Using Telegraf
 
Around the world with extensions | PostgreSQL Conference Europe 2018 | Craig ...
Around the world with extensions | PostgreSQL Conference Europe 2018 | Craig ...Around the world with extensions | PostgreSQL Conference Europe 2018 | Craig ...
Around the world with extensions | PostgreSQL Conference Europe 2018 | Craig ...
 
Climate data in r with the raster package
Climate data in r with the raster packageClimate data in r with the raster package
Climate data in r with the raster package
 
Big Data Day LA 2015 - Large Scale Distinct Count -- The HyperLogLog algorith...
Big Data Day LA 2015 - Large Scale Distinct Count -- The HyperLogLog algorith...Big Data Day LA 2015 - Large Scale Distinct Count -- The HyperLogLog algorith...
Big Data Day LA 2015 - Large Scale Distinct Count -- The HyperLogLog algorith...
 
Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...
Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...
Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...
 
HyperLogLog in Hive - How to count sheep efficiently?
HyperLogLog in Hive - How to count sheep efficiently?HyperLogLog in Hive - How to count sheep efficiently?
HyperLogLog in Hive - How to count sheep efficiently?
 
Collecting metrics with Graphite and StatsD
Collecting metrics with Graphite and StatsDCollecting metrics with Graphite and StatsD
Collecting metrics with Graphite and StatsD
 
The Weather of the Century
The Weather of the CenturyThe Weather of the Century
The Weather of the Century
 
Supercharge your Analytics with ClickHouse, v.2. By Vadim Tkachenko
Supercharge your Analytics with ClickHouse, v.2. By Vadim TkachenkoSupercharge your Analytics with ClickHouse, v.2. By Vadim Tkachenko
Supercharge your Analytics with ClickHouse, v.2. By Vadim Tkachenko
 
The Weather of the Century Part 3: Visualization
The Weather of the Century Part 3: VisualizationThe Weather of the Century Part 3: Visualization
The Weather of the Century Part 3: Visualization
 

Similar to Trading volume mapping R in recent environment

Apache Cassandra at Macys
Apache Cassandra at MacysApache Cassandra at Macys
Apache Cassandra at Macys
DataStax Academy
 
Adios hadoop, Hola Spark! T3chfest 2015
Adios hadoop, Hola Spark! T3chfest 2015Adios hadoop, Hola Spark! T3chfest 2015
Adios hadoop, Hola Spark! T3chfest 2015
dhiguero
 
Examining Oracle GoldenGate Trail Files
Examining Oracle GoldenGate Trail FilesExamining Oracle GoldenGate Trail Files
Examining Oracle GoldenGate Trail Files
Bobby Curtis
 
New Developments in Spark
New Developments in SparkNew Developments in Spark
New Developments in Spark
Databricks
 
Introduction to R for data science
Introduction to R for data scienceIntroduction to R for data science
Introduction to R for data science
Long Nguyen
 
Dataiku - hadoop ecosystem - @Epitech Paris - janvier 2014
Dataiku  - hadoop ecosystem - @Epitech Paris - janvier 2014Dataiku  - hadoop ecosystem - @Epitech Paris - janvier 2014
Dataiku - hadoop ecosystem - @Epitech Paris - janvier 2014
Dataiku
 
Pivotal Greenplum 次世代マルチクラウド・データ分析プラットフォーム
Pivotal Greenplum 次世代マルチクラウド・データ分析プラットフォームPivotal Greenplum 次世代マルチクラウド・データ分析プラットフォーム
Pivotal Greenplum 次世代マルチクラウド・データ分析プラットフォーム
Masayuki Matsushita
 
Taboola's experience with Apache Spark (presentation @ Reversim 2014)
Taboola's experience with Apache Spark (presentation @ Reversim 2014)Taboola's experience with Apache Spark (presentation @ Reversim 2014)
Taboola's experience with Apache Spark (presentation @ Reversim 2014)
tsliwowicz
 
Scaling PostgreSQL With GridSQL
Scaling PostgreSQL With GridSQLScaling PostgreSQL With GridSQL
Scaling PostgreSQL With GridSQL
Jim Mlodgenski
 
Improving Apache Spark Downscaling
 Improving Apache Spark Downscaling Improving Apache Spark Downscaling
Improving Apache Spark Downscaling
Databricks
 
[JSS2015] In memory and operational analytics
[JSS2015] In memory and operational analytics[JSS2015] In memory and operational analytics
[JSS2015] In memory and operational analytics
GUSS
 
Jss 2015 in memory and operational analytics
Jss 2015   in memory and operational analyticsJss 2015   in memory and operational analytics
Jss 2015 in memory and operational analytics
David Barbarin
 
Hadoop
HadoopHadoop
Improving the performance of Odoo deployments
Improving the performance of Odoo deploymentsImproving the performance of Odoo deployments
Improving the performance of Odoo deployments
Odoo
 
HadoopThe Hadoop Java Software Framework
HadoopThe Hadoop Java Software FrameworkHadoopThe Hadoop Java Software Framework
HadoopThe Hadoop Java Software Framework
ThoughtWorks
 
Extreme Replication - RMOUG Presentation
Extreme Replication - RMOUG PresentationExtreme Replication - RMOUG Presentation
Extreme Replication - RMOUG Presentation
Bobby Curtis
 
The Tidyverse and the Future of the Monitoring Toolchain
The Tidyverse and the Future of the Monitoring ToolchainThe Tidyverse and the Future of the Monitoring Toolchain
The Tidyverse and the Future of the Monitoring Toolchain
John Rauser
 
HIVE: Data Warehousing & Analytics on Hadoop
HIVE: Data Warehousing & Analytics on HadoopHIVE: Data Warehousing & Analytics on Hadoop
HIVE: Data Warehousing & Analytics on HadoopZheng Shao
 
Complex realtime event analytics using BigQuery @Crunch Warmup
Complex realtime event analytics using BigQuery @Crunch WarmupComplex realtime event analytics using BigQuery @Crunch Warmup
Complex realtime event analytics using BigQuery @Crunch Warmup
Márton Kodok
 
Improve your SQL workload with observability
Improve your SQL workload with observabilityImprove your SQL workload with observability
Improve your SQL workload with observability
OVHcloud
 

Similar to Trading volume mapping R in recent environment (20)

Apache Cassandra at Macys
Apache Cassandra at MacysApache Cassandra at Macys
Apache Cassandra at Macys
 
Adios hadoop, Hola Spark! T3chfest 2015
Adios hadoop, Hola Spark! T3chfest 2015Adios hadoop, Hola Spark! T3chfest 2015
Adios hadoop, Hola Spark! T3chfest 2015
 
Examining Oracle GoldenGate Trail Files
Examining Oracle GoldenGate Trail FilesExamining Oracle GoldenGate Trail Files
Examining Oracle GoldenGate Trail Files
 
New Developments in Spark
New Developments in SparkNew Developments in Spark
New Developments in Spark
 
Introduction to R for data science
Introduction to R for data scienceIntroduction to R for data science
Introduction to R for data science
 
Dataiku - hadoop ecosystem - @Epitech Paris - janvier 2014
Dataiku  - hadoop ecosystem - @Epitech Paris - janvier 2014Dataiku  - hadoop ecosystem - @Epitech Paris - janvier 2014
Dataiku - hadoop ecosystem - @Epitech Paris - janvier 2014
 
Pivotal Greenplum 次世代マルチクラウド・データ分析プラットフォーム
Pivotal Greenplum 次世代マルチクラウド・データ分析プラットフォームPivotal Greenplum 次世代マルチクラウド・データ分析プラットフォーム
Pivotal Greenplum 次世代マルチクラウド・データ分析プラットフォーム
 
Taboola's experience with Apache Spark (presentation @ Reversim 2014)
Taboola's experience with Apache Spark (presentation @ Reversim 2014)Taboola's experience with Apache Spark (presentation @ Reversim 2014)
Taboola's experience with Apache Spark (presentation @ Reversim 2014)
 
Scaling PostgreSQL With GridSQL
Scaling PostgreSQL With GridSQLScaling PostgreSQL With GridSQL
Scaling PostgreSQL With GridSQL
 
Improving Apache Spark Downscaling
 Improving Apache Spark Downscaling Improving Apache Spark Downscaling
Improving Apache Spark Downscaling
 
[JSS2015] In memory and operational analytics
[JSS2015] In memory and operational analytics[JSS2015] In memory and operational analytics
[JSS2015] In memory and operational analytics
 
Jss 2015 in memory and operational analytics
Jss 2015   in memory and operational analyticsJss 2015   in memory and operational analytics
Jss 2015 in memory and operational analytics
 
Hadoop
HadoopHadoop
Hadoop
 
Improving the performance of Odoo deployments
Improving the performance of Odoo deploymentsImproving the performance of Odoo deployments
Improving the performance of Odoo deployments
 
HadoopThe Hadoop Java Software Framework
HadoopThe Hadoop Java Software FrameworkHadoopThe Hadoop Java Software Framework
HadoopThe Hadoop Java Software Framework
 
Extreme Replication - RMOUG Presentation
Extreme Replication - RMOUG PresentationExtreme Replication - RMOUG Presentation
Extreme Replication - RMOUG Presentation
 
The Tidyverse and the Future of the Monitoring Toolchain
The Tidyverse and the Future of the Monitoring ToolchainThe Tidyverse and the Future of the Monitoring Toolchain
The Tidyverse and the Future of the Monitoring Toolchain
 
HIVE: Data Warehousing & Analytics on Hadoop
HIVE: Data Warehousing & Analytics on HadoopHIVE: Data Warehousing & Analytics on Hadoop
HIVE: Data Warehousing & Analytics on Hadoop
 
Complex realtime event analytics using BigQuery @Crunch Warmup
Complex realtime event analytics using BigQuery @Crunch WarmupComplex realtime event analytics using BigQuery @Crunch Warmup
Complex realtime event analytics using BigQuery @Crunch Warmup
 
Improve your SQL workload with observability
Improve your SQL workload with observabilityImprove your SQL workload with observability
Improve your SQL workload with observability
 

More from Nagi Teramo

第86回R勉強会@東京 LT資料
第86回R勉強会@東京 LT資料第86回R勉強会@東京 LT資料
第86回R勉強会@東京 LT資料
Nagi Teramo
 
Rでを作る
Rでを作るRでを作る
Rでを作る
Nagi Teramo
 
Reproducebility 100倍 Dockerマン
Reproducebility 100倍 DockerマンReproducebility 100倍 Dockerマン
Reproducebility 100倍 Dockerマン
Nagi Teramo
 
healthplanetパッケージで 体組成データを手に入れて 健康な体も手に入れる
healthplanetパッケージで体組成データを手に入れて健康な体も手に入れるhealthplanetパッケージで体組成データを手に入れて健康な体も手に入れる
healthplanetパッケージで 体組成データを手に入れて 健康な体も手に入れる
Nagi Teramo
 
闇と向き合う
闇と向き合う闇と向き合う
闇と向き合う
Nagi Teramo
 
機械の体を手に入れるのよ、 鉄郎!!!
機械の体を手に入れるのよ、鉄郎!!!機械の体を手に入れるのよ、鉄郎!!!
機械の体を手に入れるのよ、 鉄郎!!!
Nagi Teramo
 
続わかりやすいパターン認識11章(11.1 - 11.4)
続わかりやすいパターン認識11章(11.1 - 11.4)続わかりやすいパターン認識11章(11.1 - 11.4)
続わかりやすいパターン認識11章(11.1 - 11.4)Nagi Teramo
 
5分でわかるかもしれないglmnet
5分でわかるかもしれないglmnet5分でわかるかもしれないglmnet
5分でわかるかもしれないglmnetNagi Teramo
 
Ultra Lightning Talk × 3
Ultra Lightning Talk × 3Ultra Lightning Talk × 3
Ultra Lightning Talk × 3
Nagi Teramo
 
F#談話室(17)
F#談話室(17)F#談話室(17)
F#談話室(17)
Nagi Teramo
 
RFinanceJはじめました
RFinanceJはじめましたRFinanceJはじめました
RFinanceJはじめました
Nagi Teramo
 
東京R非公式おじさんが教える本当に気持ちいいパッケージ作成法
東京R非公式おじさんが教える本当に気持ちいいパッケージ作成法東京R非公式おじさんが教える本当に気持ちいいパッケージ作成法
東京R非公式おじさんが教える本当に気持ちいいパッケージ作成法
Nagi Teramo
 
お前の逐モン、GETだぜ!
お前の逐モン、GETだぜ!お前の逐モン、GETだぜ!
お前の逐モン、GETだぜ!
Nagi Teramo
 
~knitr+pandocではじめる~『R MarkdownでReproducible Research』
~knitr+pandocではじめる~『R MarkdownでReproducible Research』~knitr+pandocではじめる~『R MarkdownでReproducible Research』
~knitr+pandocではじめる~『R MarkdownでReproducible Research』
Nagi Teramo
 
とある金融屋の統計技師が時系列解析してみた
とある金融屋の統計技師が時系列解析してみたとある金融屋の統計技師が時系列解析してみた
とある金融屋の統計技師が時系列解析してみた
Nagi Teramo
 
可視化周辺の進化がヤヴァイ~rChartsを中心として~
可視化周辺の進化がヤヴァイ~rChartsを中心として~可視化周辺の進化がヤヴァイ~rChartsを中心として~
可視化周辺の進化がヤヴァイ~rChartsを中心として~
Nagi Teramo
 
「plyrパッケージで君も前処理スタ☆」改め「plyrパッケージ徹底入門」
「plyrパッケージで君も前処理スタ☆」改め「plyrパッケージ徹底入門」「plyrパッケージで君も前処理スタ☆」改め「plyrパッケージ徹底入門」
「plyrパッケージで君も前処理スタ☆」改め「plyrパッケージ徹底入門」
Nagi Teramo
 
Tokyo.R 白熱教室「これからのRcppの話をしよう」
Tokyo.R 白熱教室「これからのRcppの話をしよう」Tokyo.R 白熱教室「これからのRcppの話をしよう」
Tokyo.R 白熱教室「これからのRcppの話をしよう」
Nagi Teramo
 
レプリカ交換モンテカルロ法で乱数の生成
レプリカ交換モンテカルロ法で乱数の生成レプリカ交換モンテカルロ法で乱数の生成
レプリカ交換モンテカルロ法で乱数の生成
Nagi Teramo
 
Rで学ぶ逆変換(逆関数)法
Rで学ぶ逆変換(逆関数)法Rで学ぶ逆変換(逆関数)法
Rで学ぶ逆変換(逆関数)法
Nagi Teramo
 

More from Nagi Teramo (20)

第86回R勉強会@東京 LT資料
第86回R勉強会@東京 LT資料第86回R勉強会@東京 LT資料
第86回R勉強会@東京 LT資料
 
Rでを作る
Rでを作るRでを作る
Rでを作る
 
Reproducebility 100倍 Dockerマン
Reproducebility 100倍 DockerマンReproducebility 100倍 Dockerマン
Reproducebility 100倍 Dockerマン
 
healthplanetパッケージで 体組成データを手に入れて 健康な体も手に入れる
healthplanetパッケージで体組成データを手に入れて健康な体も手に入れるhealthplanetパッケージで体組成データを手に入れて健康な体も手に入れる
healthplanetパッケージで 体組成データを手に入れて 健康な体も手に入れる
 
闇と向き合う
闇と向き合う闇と向き合う
闇と向き合う
 
機械の体を手に入れるのよ、 鉄郎!!!
機械の体を手に入れるのよ、鉄郎!!!機械の体を手に入れるのよ、鉄郎!!!
機械の体を手に入れるのよ、 鉄郎!!!
 
続わかりやすいパターン認識11章(11.1 - 11.4)
続わかりやすいパターン認識11章(11.1 - 11.4)続わかりやすいパターン認識11章(11.1 - 11.4)
続わかりやすいパターン認識11章(11.1 - 11.4)
 
5分でわかるかもしれないglmnet
5分でわかるかもしれないglmnet5分でわかるかもしれないglmnet
5分でわかるかもしれないglmnet
 
Ultra Lightning Talk × 3
Ultra Lightning Talk × 3Ultra Lightning Talk × 3
Ultra Lightning Talk × 3
 
F#談話室(17)
F#談話室(17)F#談話室(17)
F#談話室(17)
 
RFinanceJはじめました
RFinanceJはじめましたRFinanceJはじめました
RFinanceJはじめました
 
東京R非公式おじさんが教える本当に気持ちいいパッケージ作成法
東京R非公式おじさんが教える本当に気持ちいいパッケージ作成法東京R非公式おじさんが教える本当に気持ちいいパッケージ作成法
東京R非公式おじさんが教える本当に気持ちいいパッケージ作成法
 
お前の逐モン、GETだぜ!
お前の逐モン、GETだぜ!お前の逐モン、GETだぜ!
お前の逐モン、GETだぜ!
 
~knitr+pandocではじめる~『R MarkdownでReproducible Research』
~knitr+pandocではじめる~『R MarkdownでReproducible Research』~knitr+pandocではじめる~『R MarkdownでReproducible Research』
~knitr+pandocではじめる~『R MarkdownでReproducible Research』
 
とある金融屋の統計技師が時系列解析してみた
とある金融屋の統計技師が時系列解析してみたとある金融屋の統計技師が時系列解析してみた
とある金融屋の統計技師が時系列解析してみた
 
可視化周辺の進化がヤヴァイ~rChartsを中心として~
可視化周辺の進化がヤヴァイ~rChartsを中心として~可視化周辺の進化がヤヴァイ~rChartsを中心として~
可視化周辺の進化がヤヴァイ~rChartsを中心として~
 
「plyrパッケージで君も前処理スタ☆」改め「plyrパッケージ徹底入門」
「plyrパッケージで君も前処理スタ☆」改め「plyrパッケージ徹底入門」「plyrパッケージで君も前処理スタ☆」改め「plyrパッケージ徹底入門」
「plyrパッケージで君も前処理スタ☆」改め「plyrパッケージ徹底入門」
 
Tokyo.R 白熱教室「これからのRcppの話をしよう」
Tokyo.R 白熱教室「これからのRcppの話をしよう」Tokyo.R 白熱教室「これからのRcppの話をしよう」
Tokyo.R 白熱教室「これからのRcppの話をしよう」
 
レプリカ交換モンテカルロ法で乱数の生成
レプリカ交換モンテカルロ法で乱数の生成レプリカ交換モンテカルロ法で乱数の生成
レプリカ交換モンテカルロ法で乱数の生成
 
Rで学ぶ逆変換(逆関数)法
Rで学ぶ逆変換(逆関数)法Rで学ぶ逆変換(逆関数)法
Rで学ぶ逆変換(逆関数)法
 

Recently uploaded

Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 

Recently uploaded (20)

Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 

Trading volume mapping R in recent environment

  • 1. Trading volume mapping in recent environment Global Tokyo. 1 @teramonagi
  • 2. Motivation of this Talk • is rapidly evolving in recent years. • Greate packages are appearing one after another!!! • Needless to say, googleVis too • Let me show how to use these for data analysis in this presentation 1. Data manipulation by dplyr 2. Visualization by rMaps 2
  • 3. Libraries to be needed 3 library(data.table) library(rMaps) library(dplyr) library(magrittr) library(countrycode) library(xts) library(pings)
  • 4. 4 I forgot to use googleVis Sorry!!!
  • 5. 5 Before we get on the main subject
  • 6. Fantastic collaboration -dplyr, magrittr, pings- • You can chain commands with forward-pipe operator %>% (magrittr) • Data manipulation like “mutate”, “group_by”, “summarize” (dplyr) • Soundlize(?) data manipulation (pings) 6
  • 7. Fantastic collaboration -dplyr, magrittr, pings- • Install and load packages 7 library(devtools) install_github(“dichika/pings”) install.packages(c(“dplyr”, “magrittr”)) library(pings) library(dplyr) library(magrittr)
  • 8. You can write like this(dplyr+magritter): 8 iris %>% #add new column “width” mutate(Width=Sepal.Width+Petal.Width) %>% #grouping data by species group_by(Species) %>% #calculate mean value of Width column summarize(AverageWidth=mean(Width)) %>% #Extract only the column “AverageWidth” use_series(AverageWidth) %>% #Dvide AverageWidth value by 3 divide_by(3) %>% #Get the maximum value of AverageWidth/3 max
  • 9. You can write like this(dplyr+magritter+pings): 9 pings(iris %>% #add new column “width” mutate(Width=Sepal.Width+Petal.Width) %>% #grouping data by species group_by(Species) %>% #calculate mean value of Width column summarize(AverageWidth=mean(Width)) %>% #Extract only the column “AverageWidth” use_series(AverageWidth) %>% #Dvide AverageWidth value by 3 divide_by(3) %>% #Get the maximum value of AverageWidth/3 max)
  • 10. 10 You will be hooked on this sound
  • 11. 11 Get back to the main subject
  • 12. Data for analysis…. • I prepared trading volume data • It is already formed • I used “data.table” package which gives us the function to fast speed data loading(fread function) 12
  • 13. Data for analysis… 13 > str(x) Classes ‘data.table’ and 'data.frame': 21245 obs. of 5 variables: $ Date : Date, format: "2012-11-01" "2012-11- 01" ... $ User_Country: chr "AR" "AT" "AU" "BD" ... $ Amount : num 775582 931593 565871 566 7986 ... $ ISO3C : chr "ARG" "AUT" "AUS" "BGD" ... $ Date2 : num 15645 15645 15645 15645 15645 ... - attr(*, ".internal.selfref")= > head(x) Date User_Country Amount ISO3C Date2 1 2012-11-01 AR 775581.543 ARG 15645 2 2012-11-01 AT 931592.986 AUT 15645 3 2012-11-01 AU 565870.994 AUS 15645 4 2012-11-01 BD 565.863 BGD 15645 5 2012-11-01 BE 7985.860 BEL 15645 6 2012-11-01 BG 56863.958 BGR 15645
  • 14. Data processing by dplyr 14 > xs <- x %>% + mutate(YearMonth=as.yearmon(Date)) %>% + group_by(YearMonth, ISO3C) %>% + summarize(Amount=floor(sum(Amount)/10^4)) > head(xs) YearMonth ISO3C Amount 1 11 2012 ALB 0 2 11 2012 ARE 7 3 11 2012 ARG 647 4 11 2012 AUS 2153 5 11 2012 AUT 503 6 11 2012 BEL 41
  • 15. Data processing by dplyr 15 > xs <- xs %>% + tally %>% + select(YearMonth) %>% + mutate(Counter=row_number(YearMonth)) %>% + inner_join(y=xs) > head(xs) YearMonth Counter ISO3C Amount 1 11 2012 1 ALB 0 2 11 2012 1 ARE 7 3 11 2012 1 ARG 647 4 11 2012 1 AUS 2153
  • 16. Data processing by dplyr • Define some variables we use later 16 > min.date <- xs %>% + use_series(YearMonth) %>% + as.Date %>% min %>% as.character > max.counter <- xs %>% + use_series(Counter) %>% max > min.date [1] "2012-11-01" > max.counter [1] 12
  • 17. Visualize with rMaps • Install and load rMaps 17 library(devtools) install_github('ramnathv/rCharts@dev') install_github('ramnathv/rMaps') library(rMaps)
  • 18. Visualize with rMaps • Easy to visualize yearly data • But, we have monthly data • We need to customize template HTML and javascript code • Little bit long code… 18
  • 19. Visualize with rMaps 19 d <- ichoropleth(log(Amount) ~ ISO3C, data=as.data.frame(xs), animate="Counter", map="world") d$setTemplate(chartDiv = sprintf(" <div class='container'> <button ng-click='animateMap()'>Play</button> <span ng-bind='date_show'></span> <div id='{{chartId}}' class='rChart datamaps'></div> </div> <script src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'></script> <script src='http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js'></script> <script> function rChartsCtrl($scope, $timeout){ $scope.counter = 1; $scope.date = new Date('%s'); $scope.date_show = $.datepicker.formatDate('yy-mm', $scope.date); $scope.animateMap = function(){ if ($scope.counter > %s){ return; } map{{chartId}}.updateChoropleth(chartParams.newData[$scope.counter]); $scope.counter += 1; $scope.date.setMonth($scope.date.getMonth()+1); $scope.date_show = $.datepicker.formatDate('yy-mm', $scope.date); $timeout($scope.animateMap, 1000) } } </script>", min.date, max.counter) ) d
  • 21. All Codes in this presentation: 21 github.com/teramonagi/GlobalTokyoR1