Blog on Data Science Mathematics. Statistics. Algorithms.
Posts with the tag Programming in R:

Making requests to the Open Dota API in R

In this tutorial, we are going to show how one can gather data about the esports game Dota 2 from a dedicated site collecting and providing such data. The data will be requested through the web site’s API interface documented here: The Open Dota API Documentation. First, we’re going to cover the basics of accessing an API using the R programming language. APIs allow programmers to request data directly from certain websites through what’s called an Application Programming Interface. When a website sets up an API, they are essentially setting up a computer that waits for data requests. Once this computer receives a data request, it will do its own processing of the data and send it to the computer that requested it.

Reading multiple csv files in R

Comma-separated value (csv) files are one of the most common file formats used in data analysis today. Sometimes we need to read multiple csv files from disk and combine them into a single data frame or data table object in R. We shall explore five different approaches to that task and determine the most efficient one. First, let us make sure that we know how to answer the following question: How to list the files in a given directory? The function list.files() lists all files in a given directory whose names contain a specific character pattern. An example of its use can be the following: list.files(path = "./csv/", pattern = "^f.*199", full.names = TRUE) [1] "./csv/football-results-1998.csv" "./csv/football-results-1999.csv" The output is a character vector giving the names of the files matching the search criterion.