How do I import a CSV file in R?

RCsvImport

R Problem Overview


I have a .csv file in my workstation. How can I open that file in R and do statistical calculation?

R Solutions


Solution 1 - R

You would use the read.csv function; for example:

dat = read.csv("spam.csv", header = TRUE)

You can also reference this tutorial for more details.

Note: make sure the .csv file to read is in your working directory (using getwd()) or specify the right path to file. If you want, you can set the current directory using setwd.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionUselesssssView Question on Stackoverflow
Solution 1 - RPaul HiemstraView Answer on Stackoverflow