3
我正在学习R,并被要求使用pi2000数据集,可在simpleR库(http://www.math.csi.cuny.edu/Statistics/R/simpleR/index.html/simpleR.R)处获得。然后我下载了这个文件。我如何将它导入命令行?从R文件导入东西
我正在学习R,并被要求使用pi2000数据集,可在simpleR库(http://www.math.csi.cuny.edu/Statistics/R/simpleR/index.html/simpleR.R)处获得。然后我下载了这个文件。我如何将它导入命令行?从R文件导入东西
使用source
功能:
> source("http://www.math.csi.cuny.edu/Statistics/R/simpleR/index.html/simpleR.R")
然后可以访问其中定义的变量:
> vacation
[1] 23 12 10 34 25 16 27 18 28 13 14 20 8 21 23 33 30 13 16 14 38 19 6 11 15 21 10
[28] 39 42 25 12 17 19 26 20
获得更多信息,类型?source
到R端子。
你的意思是将函数加载到R中?如果是这样,请使用source()
:
source("http://www.math.csi.cuny.edu/Statistics/R/simpleR/index.html/simpleR.R")
谢谢亚历克斯! :) – lucasn 2012-01-03 05:26:17
@亚历布朗谢谢!它只是加载r文件的方法吗? – verystrongjoe 2015-10-15 06:07:58
@verystrongjoe,不,当然不是,因为R有'eval',它有'library',所以有很多方法可以做到。但是,这是R设计人员为您创建的将R文件内嵌到第二个文件的方式。另请参阅'?source'以了解可用的选项。 – 2015-10-23 18:37:40