r - R:从网站导入脚本
问题描述
我想知道它是否可能从互联网站点导入或读取脚本,我想从以下位置导入脚本:http: //archived.stat.ufl.edu/casella/StatDesign/WebRPrograms/
我确实尝试过
setwd("http://archived.stat.ufl.edu/casella/StatDesign/WebRPrograms/")
或者
script=source("http://archived.stat.ufl.edu/casella/StatDesign/WebRPrograms/FishTank.R")
但是给了我一个错误。提前致谢
解决方案
这些看起来像您需要以交互方式使用的文件(例如,在 RStudio 中打开它们),因为它们包含指向文件的绝对链接(例如read.table("c:/Work08/StatDesignSC08/Data/Alfalfa.txt",sep = "",header=T)
)。我建议你下载它们然后打开它们。例如使用这些命令:
source_file <- "http://archived.stat.ufl.edu/casella/StatDesign/WebRPrograms/Alfalfa.R"
download.file(url = source_file, destfile = basename(source_file))
file.edit(basename(source_file))
然后编辑您需要的路径。否则,您将不断遇到cannot open file
错误。
推荐阅读
- go - 为什么 encoding/json 将切片编组为 base64?
- html - 将数据加载到 html 页面上的图表中
- javascript - 单击 asp:button 时显示和隐藏面板
- c++ - 如何在 C++ STL 的集合中找到有序的后继或前驱
- r - 从 IC2 函数中提取数字
- regex - 正则表达式:我怎样才能匹配第一个
- shell - 如何删除名称中包含 Ctrl-M 的文件?
- r - 如何使用在 r 中重复的另一个数据框中的特定列更新数据框中的新列?
- cassandra - 在 Cassandra 中,与压缩期间的行/单元墓碑相比,分区墓碑本质上是否更便宜?
- java - Mapbox轨迹视图Android