使用Ubuntu中的read.csv将csv导入R中

时间:2014-02-28 18:14:00

标签: r ubuntu read.table

我刚刚在我的计算机上安装了Ubuntu,并且我正在重新运行以前在Windows中运行的一些代码。我已经用我的所有文件将我的目录复制到Ubuntu中。

当我运行这行代码将数据库导入R时,我收到以下错误:

Annot <- read.csv("~/Documents/DATABASES/Functional_Annotations/Salar_2_Annot_light.csv", header = TRUE)
Error in file(file, "rt") : cannot open the connection
In addition: Warning message: In file(file, "rt") :   cannot open file
'/home/cd46/Documents/DATABASES/Functional_Annotations/Salar_2_Annot_light.csv':
No such file or directory

代码是对的,以前没有改变过。事实上,如果我跑:

setwd("~/Documents/DATABASES/Functional_Annotations")

它工作正常并识别目录。并将文件存放在那里。

我不确定这是什么,有人有什么建议吗?我唯一要做的就是切换到Ubuntu,所以我想象问题就在那里。

1 个答案:

答案 0 :(得分:0)

我在R中安装了readr软件包 然后简单地写下:

df&lt; - read_csv(&#34; / your path / file.csv&#34;) 这对我有用,并解决了这个问题。