我一直在探索一些R
语义,我对PACKAGE
接口.External
参数的工作方式感到有些困惑。
例如,来自rnorm
包的stats
。使用命名空间查找它可以工作:
> rnorm
function (n, mean = 0, sd = 1)
.External(C_rnorm, n, mean, sd)
<bytecode: 0x102874270>
<environment: namespace:stats>
> .External(stats:::C_rnorm, 10, 0, 1)
[1] -0.2363370 0.9323128 0.9551952 0.2108897 -0.1170138 1.1439723 1.7838458 1.1358356 0.8431536 0.6363356
但是如果我尝试使用PACKAGE
参数:
> .External("C_rnorm", 10, 0, 1, PACKAGE="stats")
Error in .External("C_rnorm", 10, 0, 1, PACKAGE = "stats") :
"C_rnorm" not available for .External() for package "stats"
> .External("rnorm", 10, 0, 1, PACKAGE="stats")
Error in .External("rnorm", 10, 0, 1, PACKAGE = "stats") :
"rnorm" not available for .External() for package "stats"
我做错了什么?