How to Read CSV Data from The Web in R

03.28.2021

Many data is provided and hosted on website. For example, there are many datasets on Github and Kaggle that you can use in Data Science. R provides a nice way to easily read this data. In this article, we will learn how to read csv from the web.

To read csv from a url, we can use the read_csv function and pass it a url. That way, we don't have to download the file. R will read it directly into a data frame. In the example below, R downloads a csv from github directly into a dataframe.

df = read_csv('https://gist.githubusercontent.com/CerebralMastication/ef60173782962b1c844864ebc2774c9b/raw/78d867fd1b6f56b96171074beaaf28e2c3a3a04e/web_example.csv')