<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/analysing-cryptocurrency-market-in-r/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://datascienceplus.com/analysing-cryptocurrency-market-in-r/"> R Programming – DataScience+</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Cryptocurrency market has been growing rapidly that being an Analyst, It intrigued me what does it comprise of. In this post, I’ll explain how can we analyse the Cryptocurrency Market in R with the help of the package <code>coinmarketcapr</code>. Coinmarketcapr package is an R wrapper around coinmarketcap API.</p>
<p>To get started, Let us load the library into our R session and Plot the top 5 Cryptocurrencies.</p>
<pre>
library(coinmarketcapr)
plot_top_5_currencies()
</pre>
<p>Gives this plot:<br>
<a rel="nofollow" href="https://i2.wp.com/datascienceplus.com/wp-content/uploads/2017/10/cryptocurrency_top_5.png?ssl=1" target="_blank"><img sizes="(max-width: 490px) 100vw, 490px" src="https://i0.wp.com/datascienceplus.com/wp-content/uploads/2017/10/cryptocurrency_top_5-490x490.png?w=450&ssl=1" alt="" class="wp-image-9163" data-recalc-dims="1"></a></p>
<p>The above plot clearly shows how bitcoin is leading the market but that does not give us the picture of how the marketshare is split among various cryptocurrencies, so let us get the complete data of various cryptocurrencies.</p>
<pre>
market_today &lt;- get_marketcap_ticker_all()
head(market_today[,1:8])
<em> id name symbol rank price_usd price_btc X24h_volume_usd market_cap_usd
1 bitcoin Bitcoin BTC 1 5568.99 1.0 2040540000.0 92700221345.0
2 ethereum Ethereum ETH 2 297.408 0.0537022 372802000.0 28347433482.0
3 ripple Ripple XRP 3 0.204698 0.00003696 100183000.0 7887328954.0
4 bitcoin-cash Bitcoin Cash BCH 4 329.862 0.0595624 156369000.0 5512868154.0
5 litecoin Litecoin LTC 5 55.431 0.010009 124636000.0 2967255097.0
6 dash Dash DASH 6 287.488 0.0519109 46342600.0 2197137527.0
</em>
</pre>
<p>Having extracted the complete data of various cryptocurrencies, let us try to visualize the marketshare split with a <code>treemap</code>. For plotting, let us extract only the two columns <em>ID</em> and <em>market_cap_usd</em> and convert the <em>market_cap_usd</em> into numeric type and a little bit of number formatting for the treemap labels. </p>
<pre>
library(treemap)
df1 &lt;- na.omit(market_today[,c('id','market_cap_usd')])
df1$market_cap_usd &lt;- as.numeric(df1$market_cap_usd)
df1$formatted_market_cap &lt;-  paste0(df1$id,'\n','$',format(df1$market_cap_usd,big.mark = ',',scientific = F, trim = T))
treemap(df1, index = 'formatted_market_cap', vSize = 'market_cap_usd', title = 'Cryptocurrency Market Cap', fontsize.labels=c(12, 8), palette='RdYlGn')
</pre>
<p>Gives this plot:<br>
<a rel="nofollow" href="https://i2.wp.com/datascienceplus.com/wp-content/uploads/2017/10/cryptocurrency_marketshare_split.png?ssl=1" target="_blank"><img sizes="(max-width: 490px) 100vw, 490px" src="https://i0.wp.com/datascienceplus.com/wp-content/uploads/2017/10/cryptocurrency_marketshare_split-490x490.png?w=450&ssl=1" alt="" class="wp-image-9168" data-recalc-dims="1"></a></p>
<p>The above visualization explains the whole cryptocurrency market is propped by two currencies primarily – Bitcoin and Etherum and even the second ranked Etherum is far behind than Bitcoin which is the driving factor of this market. But it is also fascinating (and shocking at the same time) that both Bitcoin and Etherum together create a 100 Billion Dollar (USD) market. Whether this is a sign of bubble or no – We’ll leave that for market analysts to speculate, but being a data scientist or analyst, We have a lot of insights to extract from the above data and it should be interesting analysing such an expensive market. </p>
<ul></ul>
<p><strong>
<p>Related Post</p>
<p></p></strong>
<ol>
<li><a rel="nofollow" href="https://datascienceplus.com/time-series-analysis-in-r-part-3-getting-data-from-quandl/" title="Permanent Link toTime Series Analysis in R Part 3: Getting Data from Quandl" target="_blank">Time Series Analysis in R Part 3: Getting Data from Quandl</a></li>
<li><a rel="nofollow" href="https://datascienceplus.com/pulling-data-out-of-census-spreadsheets-using-r/" title="Permanent Link toPulling Data Out of Census Spreadsheets Using R" target="_blank">Pulling Data Out of Census Spreadsheets Using R</a></li>
<li><a rel="nofollow" href="https://datascienceplus.com/extracting-tables-from-pdfs-in-r-using-the-tabulizer-package/" title="Permanent Link toExtracting Tables from PDFs in R using the Tabulizer Package" target="_blank">Extracting Tables from PDFs in R using the Tabulizer Package</a></li>
<li><a rel="nofollow" href="https://datascienceplus.com/extract-twitter-data-automatically-using-scheduler-r-package/" title="Permanent Link toExtract Twitter Data Automatically using Scheduler R package" target="_blank">Extract Twitter Data Automatically using Scheduler R package</a></li>
<li><a rel="nofollow" href="https://datascienceplus.com/introduction-to-time-series-with-json-data/" title="Permanent Link toAn Introduction to Time Series with JSON Data" target="_blank">An Introduction to Time Series with JSON Data</a></li>
</ol>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://datascienceplus.com/analysing-cryptocurrency-market-in-r/"> R Programming – DataScience+</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/XeiwYqilHIU" height="1"></a></div>