Investigating Cryptocurrencies using R

R-bloggers 2017-07-16

(This article was first published on R-Chart, and kindly contributed to R-bloggers)

Cryptocurrencies are a fascinating phenomenon and excellent data source for analysis with R.  This post will introduce how to get a list of available currencies into R.  Wikipedia maintains a page with a list of cryptocurrencies.  These can be read from HTML into a data frame.

library(httr) library(XML) results = GET(“https://en.wikipedia.org/wiki/List_of_cryptocurrencies”) doc = readHTMLTable(doc=content(results, “text”)) View(doc[1])

This list is not complete.  Also, an API would be preferable to reading a wiki page.  A publicly available API at cryptocompare.com provides similar information in JSON format.

library(jsonlite) library(data.table) response = fromJSON(‘https://www.cryptocompare.com/api/data/coinlist’) df = data.table::rbindlist(response$Data, fill=TRUE) View(df)

With a bit of shiny code, this data can be served up in a web application and published to shinyapps.io… so you can skip the R coding and review the data here if you prefer:

https://casimir.shinyapps.io/cryptocurr/

var vglnk = { key: '949efb41171ac6ec1bf7f206d57e90b8' }; (function(d, t) {var s = d.createElement(t); s.type = 'text/javascript'; s.async = true;s.src = '//cdn.viglink.com/api/vglnk.js';var r = d.getElementsByTagName(t)[0]; r.parentNode.insertBefore(s, r); }(document, 'script'));

To leave a comment for the author, please follow the link and comment on their blog: R-Chart.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...