In this project we’ll examine how the market cap of cyrptocurrencies is distributed using coinmarketcapr.
Examine how the market share is split among the top cryptocurrencies.
market_today <- get_marketcap_ticker_all()
head(market_today[,1:8])
## id name symbol rank price_usd price_btc
## 1 bitcoin Bitcoin BTC 1 4132.83948356 1.0
## 2 ripple XRP XRP 2 0.3672807888 0.00008889
## 3 ethereum Ethereum ETH 3 116.22829719 0.0281299
## 4 stellar Stellar XLM 4 0.1604106953 0.00003882
## 5 bitcoin-cash Bitcoin Cash BCH 5 171.275465081 0.04145258
## 6 eos EOS EOS 6 2.8456477787 0.00068871
## X24h_volume_usd market_cap_usd
## 1 5293482428.63 71928194608.0
## 2 337778730.768 14811457870.0
## 3 1860911271.0 12037225691.0
## 4 75895674.3008 3072586627.0
## 5 71862409.1687 2995554361.0
## 6 739888959.24 2578854406.0
Having extracted the complete data of various cryptocurrencies, we’ll visualize the marketshare split with a treemap. For plotting, let us extract only the two columns ID and market_cap_usd and convert the market_cap_usd into numeric and format numbers of treemap labels.
library(treemap)
df1 <- na.omit(market_today[,c('id','market_cap_usd')])
df1$market_cap_usd <- as.numeric(df1$market_cap_usd)
df1$formatted_market_cap <- 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')
