这个问题与其他一些问题有关,比如RccpArmadillo或element-wise-multiplication.
但是,我的设置是这样的,我不知道我有什么编辑/ simlink使Rccp运行而不给我警告.
我使用最新的R版本在Mac 10.9(小牛队)上.
在一开始,尝试从RCCpvsR得到的以下代码,我收到一个错误:
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)`
Run Code Online (Sandbox Code Playgroud)
然后,基于RccpArmadillo,我做了以下事情:
# Update FLIBS in ~/.R/Makevars
FLIBS=-L/usr/local/Cellar/gfortran/4.8.2/gfortran
#Re-Install from source
install.packages(c("Rcpp","RcppArmadillo","inline"),type="source")
#Restart R
Run Code Online (Sandbox Code Playgroud)
这是因为我没有/usr/local/Cellar/gfortran/目录所以只是尝试了.事实上,我的所有libgfortran*文件都在这里(在macports目录下):
>ls /opt/local/lib/gcc48/libgfortran.*
/opt/local/lib/gcc48/libgfortran.3.dylib /opt/local/lib/gcc48/libgfortran.dylib
/opt/local/lib/gcc48/libgfortran.a /opt/local/lib/gcc48/libgfortran.spec
Run Code Online (Sandbox Code Playgroud)
在这里/opt/local/lib/gcc48/gcc/x86_64-apple-darwin13/4.8.3/libgfortranbegin.a,我没有任何gfortran文件.
然后我再次尝试了代码RccpvsR,令人惊讶的是,它工作了!除了我得到警告的事实:
ld: warning: directory not found for option '-L/usr/local/Cellar/gfortran/4.8.2/gfortran'
Run Code Online (Sandbox Code Playgroud)
因为它当然不存在,但是该代码创建的函数cosineRcpp运行没有问题.
因此,所有这些,要问是否有人知道我是否必须将libgfortran文件链接 …
我正在研究一个需要逐元素矩阵乘法的代码.我试图在Rcpp中实现这个,因为代码需要一些昂贵的循环.我对Rcpp相当新,可能会遗漏一些东西,但我不能让元素明确的矩阵乘法起作用.
// [[Rcpp::export]]
NumericMatrix multMat(NumericMatrix m1, NumericMatrix m2) {
NumericMatrix multMatrix = m1 * m2 // How can this be implemented ?
}
Run Code Online (Sandbox Code Playgroud)
我可能会遗漏一些非常微不足道的东西,并想问是否有任何方法可以做到这一点(除了使用循环迭代每个元素并乘以).
提前致谢.
我最近更新了R到3.1.0.我试图将我的包移到R.Framework里面的3.1(我正在运行OSX Mavericks)并且不知何故弄得一团糟,所以在干净安装之前完全卸载了所有东西.
重新安装软件包时,我遇到问题,直到我点击forecast包,产生以下错误:
package ‘forecast’ is available as a source package but not as a binary
Warning in install.packages :
package ‘forecast’ is not available (for R version 3.1.0)
Run Code Online (Sandbox Code Playgroud)
我实际上有R 3.1.0并且在重新安装之前预测和hts一起工作所以我怀疑问题源于我做过的事情,而不是兼容性问题.
我运行以下内容以查看是否可以发现有关安装失败的更多详细信息: install.packages("forecast", type = "source", verbose = T, quiet = F)
其输出略高于我,但可能有助于诊断:
system (cmd0): /Library/Frameworks/R.framework/Resources/bin/R CMD INSTALL
trying URL 'http://cran.rstudio.com/src/contrib/forecast_5.3.tar.gz'
Content type 'application/x-gzip' length 150395 bytes (146 Kb)
opened URL
==================================================
downloaded 146 Kb
foundpkgs: forecast, /var/folders/0y/_13fkvws0tn5xh4m8wsymkdh0000gp/T//RtmpzTzSpG/downloaded_packages/forecast_5.3.tar.gz
files: /var/folders/0y/_13fkvws0tn5xh4m8wsymkdh0000gp/T//RtmpzTzSpG/downloaded_packages/forecast_5.3.tar.gz
* installing *source* package ‘forecast’ ...
** package …Run Code Online (Sandbox Code Playgroud)