I have a .csv
file in my workstation. How can I open that file in R and do statistical calculation?
In order to find the location of the file on Mac OS you can right click on the file and choose "Get Info"; on Windows you can right click on the file and choose "Properties". Use this local path in the file path in the read. csv() command to import the file.
The read. csv() method in base R is used to load a . csv file into the present script and work with it. The contents of the csv can be stored into the variable and further manipulated.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With