[英]R: error message — package error: “functionName” not resolved from current namespace
I am using a package that has worked up until R3.0. 我正在使用一直运行到R3.0的软件包。
the issue is as above .... when we call a function that works in R 2.15.2 from R 3.0 we get an error 问题如上所述....当我们从R 3.0调用一个在R 2.15.2中起作用的函数时,我们得到一个错误
Error in .C("solarspectrum3", as.double(lon), as.double(lat), as.double(timezone), :
"solarspectrum3" not resolved from current namespace (SolarSpectrum)
any help would be appreciated 任何帮助,将不胜感激
Alex 亚历克斯
The package could be found at https://www.dropbox.com/s/zgspdzd2rq5jmh6/SolarSpectrum_1.0.tar.gz 该软件包可在https://www.dropbox.com/s/zgspdzd2rq5jmh6/SolarSpectrum_1.0.tar.gz找到
install the package 安装包
R CMD INSTALL SolarSpectrum_1.0.tar.gz , then R CMD安装SolarSpectrum_1.0.tar.gz,然后
run 跑
require(SolarSpectrum)
longitude=2
latitude=50
date=as.POSIXct("2008-06-06")
PAR <- SolarSpectrum.PAR(longitude, latitude, date)[2]
The error should show up at this time 此错误应该出现
This error message can affect functions that call external code using calls to .C()
or .Call()
. 此错误消息可能会影响使用
.C()
或.Call()
调用调用外部代码的函数。
The problem is described well in this R-help thread ; 在这个R-help线程中很好地描述了这个问题; in particular Martin Morgan's response is useful.
特别是马丁摩根的回应很有用。 He quotes an entry to R's
NEWS
file, when version 3.0.0 was released. 当版本3.0.0发布时,他引用了R的
NEWS
文件的条目。
A foreign function call (.C() etc) in a package without a PACKAGE argument will only look in the first DLL specified in the NAMESPACE file of the package rather than searching all loaded DLLs.
没有PACKAGE参数的包中的外部函数调用(.C()等)只会查找包的NAMESPACE文件中指定的第一个DLL,而不是搜索所有加载的DLL。 A few packages needed PACKAGE arguments added.
一些包需要添加PACKAGE参数。
So the call to .C()
or .Call()
needs to be amended in the package's source, to include PACKAGE = "name_of_dll_without_extension"
. 因此,需要在包的源代码中修改对
.C()
或.Call()
的调用,以包括PACKAGE = "name_of_dll_without_extension"
。
You can find the DLL names with the following code. 您可以使用以下代码找到DLL名称。
dir(system.file("libs", package = "rpkgname"))
This may have been solved by now; 这可能已经解决了; however, try setting the PACKAGE argument for the .C call in SolarSpectrum.PAR to "SolarSpectrum" (this may involve altering the package source files for SolarSpectrum.PAR).
但是,尝试将SolarSpectrum.PAR中的.C调用的PACKAGE参数设置为“SolarSpectrum”(这可能涉及更改SolarSpectrum.PAR的包源文件)。 That may get R to look in the correct namespace (I haven't actually tried this, but it worked for a different package with the same error).
这可能让R看到正确的命名空间(我实际上没有尝试过这个,但它适用于具有相同错误的不同包)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.