我正在尝试导入一个.csv文件,以便我可以跟随这个视频:R ggplot2图形直方图.
我安装了所有适当的包,包括ggplot相关的包.视频中的第一条指令表示要键入afl.df=read.csv("afl_2003_2007.csv")
所以,我下载了afl_2003_2007.csv文件,我尝试了以下所有内容,这基本上是将文件放在不同的目录(共享驱动器,然后C驱动器等).我也试过用setwd,但没有运气.
我在Windows中使用R.
这是我尝试过的,以及我得到的错误:
> afl.df=read.csv("afl_2003_2007.csv")
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
cannot open file 'afl_2003_2007.csv': No such file or directory
> afl.df=read.csv("\\the-lab.llnl.gov\llnlusers1\lopez235\Data\Documents\Dashboards,HRBI, Visulizations and Analytics\Math and Statistics and Predictive Modeling1\R Programming\afl_2003_2007.csv")
Error: '\l' is an unrecognized escape in character string starting "\\the-lab.llnl.gov\l"
> afl.df=read.csv("C:\Users\lopez235\Local-NOTBackedUp\R Files Local\afl_2003_2007.csv")
Error: '\U' used without hex digits in character string starting "C:\U"
> setwd("\\the-lab.llnl.gov\llnlusers1\lopez235\Data\Documents\Dashboards,HRBI, Visulizations and Analytics\Math and Statistics and Predictive Modeling1\R Programming\afl_2003_2007.csv")
Error: '\l' is an unrecognized escape in character string starting "\\the-lab.llnl.gov\l"
> setwd("\\the-lab.llnl.gov\llnlusers1\lopez235\Data\Documents\Dashboards,HRBI, Visulizations and Analytics\Math and Statistics and Predictive Modeling1\R Programming")
Error: '\l' is an unrecognized escape in character string starting "\\the-lab.llnl.gov\l"
> setwd("C:\Users\lopez235\Local-NOTBackedUp\R Files Local")
Error: '\U' used without hex digits in character string starting "C:\U"
Run Code Online (Sandbox Code Playgroud)
Dav*_*son 17
使用/的,而不是\在你的路径:
afl.df=read.csv("C:/Users/lopez235/Local-NOTBackedUp/R Files Local/afl_2003_2007.csv")
Run Code Online (Sandbox Code Playgroud)