我正在尝试导入一个.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 …Run Code Online (Sandbox Code Playgroud) 我试图让自己了解R的nChooseK功能,但我无法让它发挥作用.我认为这是标准设置的一部分(即不需要额外的包).
请帮忙.这是我尝试过的:
> nChooseK(10,2)
Error: could not find function "nChooseK"
> n<-4;k<-2
> print(nChooseK(n,k))
Error in print(nChooseK(n, k)) : could not find function "nChooseK"
Run Code Online (Sandbox Code Playgroud)
最后一个是我在这里看到的一个例子:R basic nChooseK
我在这做错了什么?"下标越界"是什么意思?
我得到了下面的代码(第一块)摘录形式的革命R在线研讨会关于R中的数据挖掘.我试图将其纳入我运行的RF模型中,但无法通过我认为的变量排序.我只是想描绘变量的重要性.
我在下面添加了一些更多内容以提供上下文.但实际上我错误的是第三行代码.第二个代码块是我应用于我正在使用的数据时得到的错误.任何人都可以帮我解决这个问题吗?
-------------------------------------------------------------------------
# List the importance of the variables.
rn <- round(importance(model.rf), 2)
rn[order(rn[,3], decreasing=TRUE),]
##@# of
# Plot variable importance
varImpPlot(model.rf, main="",col="dark blue")
title(main="Variable Importance Random Forest weather.csv",
sub=paste(format(Sys.time(), "%Y-%b-%d %H:%M:%S"), Sys.info()["user"]))
#--------------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)
我的错误:
> rn[order(rn[,2], decreasing=TRUE),]
Error in order(rn[, 2], decreasing = TRUE) : subscript out of bounds
Run Code Online (Sandbox Code Playgroud) 需要像len函数一样的字符计数函数,但我需要它来取一个范围(即A1:D22).你建议我用什么?我正在寻找除了在多个列和行上填充len函数之外的其他东西,然后将它们全部加起来.我正试图用一个功能来做.这是用它作为检查值.