TC Technology Knowledge Base

Import data in R .CSV Files into R-Studio

Updated on

In order to get a .csv file into R, you can use read.csv, and as the only argument, put the path to the file you want to read in within quotation marks. Ideally, the file should be close to, if not in the same folder as, this script. That way you only need to type a relative path.

1. In the sample below, the file on the computer is called menu.csv, therefore we used the script: read.csv("menu.csv")

2. If the file is somewhere else on your computer, you can type a full path.

Note that Mac users should use single forward slashes while Windows users have to use double back slashes.

3. Create a new variable called menu and save the contents of the menu.csv file into that variable by typing: menu<-read.csv("menu.csv")

Previous Article Use Help in RStudio
Next Article Import data into R- .txt files in R-Studio