当 R 说“没有这样的文件或目录"时,如何在 R 中打开 CSV 文件? [英] How to open CSV file in R when R says "no such file or directory"?

查看:57
本文介绍了当 R 说“没有这样的文件或目录"时,如何在 R 中打开 CSV 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个想要在 R 中打开的 excel 文件.在将 excel 文件保存为 csv 文件或文本文件后,我尝试了这两个命令.

I have an excel file that I want to open in R. I tried both of these commands after saving the excel file as a csv file or a text file.

read.table() 或 read.csv()

read.table() or read.csv()

我认为部分问题在于文件所在的位置.我把它保存在桌面上.我在这里错过了什么?

I think part of the problem is where the file is located. I have it saved on the desk top. What am I missing here?

这是R输出

In file(file, "rt") :
  cannot open file 'Rtrial.csv': No such file or directory
> help.search("read.csv")
> read.csv("Rtrial.csv")
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
  cannot open file 'Rtrial.csv': No such file or directory
> read.table("tab")

推荐答案

要放弃另一个选项,为什么不使用 setwd('C:\John\Desktop') 然后只使用文件名读取文件

To throw out another option, why not set the working directory (preferably via a script) to the desktop using setwd('C:\John\Desktop') and then read the files just using file names

这篇关于当 R 说“没有这样的文件或目录"时,如何在 R 中打开 CSV 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆