vignettes/Getting_Started.Rmd
Getting_Started.Rmd
This vignette is to help you get started with Coinmarketcapr Package that helps to extract and monitor price and market cap of Cryptocurrencies from CoinMarketCap. Simply, Coinmarketcapr is an R-binding for Coinmarketcap API that lists Price, Marketcap, Transaction Volume of many Cryptocurrencies and tokens.
This function get_valid_currencies()
lists a character vector with all the valid currencies (ISO Codes) supported by Coinmarketcap API. These currency codes can be used in other functions like get_global_marketcap()
to extract values in the given currency.
This function get_global_marketcap()
fetches the USD value of global marketcap of all cryptocurrencies.
This function get_marketcap_ticker_all()
gets various useful values such as Price, Marketcap, Total Volume, 24-hour Change and much for all the cryptocurrencies.
library(coinmarketcapr)
names(get_marketcap_ticker_all())
#> [1] "id" "name" "symbol"
#> [4] "rank" "price_usd" "price_btc"
#> [7] "X24h_volume_usd" "market_cap_usd" "available_supply"
#> [10] "total_supply" "max_supply" "percent_change_1h"
#> [13] "percent_change_24h" "percent_change_7d" "last_updated"
This function plot_top_currencies()
makes it straightforward to make a barplot of top cryptocurrencies by their rank which is actually based on Market cap.
plot_top_currencies()
outputs a ggplot
object hence using +
operator a new ggplot2 theme can be applied. ggthemes
package has got a rich set of out-of-box themes to use with.
library(ggthemes)
#> Warning: package 'ggthemes' was built under R version 3.5.2
plot_top_currencies() +
theme_economist()
Since coinmarketcapr
’s get_marketcap_ticker_all()
returns a dataframe, it could be fit in alongside with Tidy Data pipeline.
library(coinmarketcapr)
library(dplyr)
#> Warning: package 'dplyr' was built under R version 3.5.2
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(ggplot2)
#> Warning: package 'ggplot2' was built under R version 3.5.2
get_marketcap_ticker_all() %>%
slice(1:30) %>%
mutate(price_usd = as.numeric(price_usd)) %>%
ggplot() + geom_histogram(aes(price_usd)) +
ggtitle('Cryptocurrencies Price in USD Histogram')
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
Coinmarketcapr is powered by Coinmarketcap.com https://coinmarketcap.com/api/