【问题标题】:cannot open destfile...reason 'Invalid argument' in Rstudio1.1.447无法打开 destfile ...原因是 Rstudio1.1.447 中的“无效参数”
【发布时间】:2018-05-16 16:43:47
【问题描述】:

我是 R 的初学者。 我的脚本是:

output_folder <-"X:\\My_R_result\\"

url<-paste("https://climexp.knmi.nl/data/icmip5_pr_Amon_ens_rcp45_79-91E_26-31N_n_su_001.dat",sep="")

destfile<-paste(output_folder,"001.dat",sep="")

download.file(url,destfile,method="auto",quiet = FALSE, mode="W",cacheOK=TRUE)

print(download.file)
print("finished")

它会弹出

download.file(url, destfile, method = "auto", quiet = FALSE, : 无法打开 destfile 'X:\My_R_result\001.dat',原因 '无效 论据”。

你能告诉我这里有什么问题吗?

【问题讨论】:

  • mode="W" 应该是 mode="w"。提示:可以使用paste0替换paste( , sep = "")
  • 谢谢你,董。它适用于“w”

标签: r download


【解决方案1】:

这应该有效: 我将您的 paste() 更改为 paste0() 命令。 mode="W" 应该是小写的 "w"。

output_folder <-"X:\\My_R_result\\"
url<-paste0("https://climexp.knmi.nl/data/icmip5_pr_Amon_ens_rcp45_79-91E_26-31N_n_su_001.dat")
destfile<-paste0(output_folder,"001.dat")
download.file(url,destfile,method="auto",quiet = FALSE, mode="w",cacheOK=TRUE)
print("finished")

而且您不能打印(下载.file),因为您只能打印函数本身,而不是下载的文本。要打印下载数据中的文本,您必须在 R 中加载它。

data <- read.table(file = destfile)
print(data)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-06
    • 1970-01-01
    • 2019-11-09
    • 2019-05-14
    相关资源
    最近更新 更多