如何在R中导入CSV文件?

时间:2022-02-24 07:08:56

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

我的工作站上有一个。csv文件。如何在R中打开该文件并进行统计计算?

1 个解决方案

#1


136  

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

你可以用这个读法。csv功能;例如:

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.

注意:请确保要读取的.csv文件位于工作目录(使用getwd())或指定文件的正确路径。如果需要,可以使用setwd设置当前目录。

#1


136  

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

你可以用这个读法。csv功能;例如:

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.

注意:请确保要读取的.csv文件位于工作目录(使用getwd())或指定文件的正确路径。如果需要,可以使用setwd设置当前目录。