install.packages + type =“source”和R CMD INSTALL --build无法安装PerformanceAnalytics

时间:2016-04-09 09:53:50

标签: r performanceanalytics

我尝试使用@GSee和@hadley在a well answered question中建议的两种方法安装最新版本的PerformanceAnalytics

我不知道哪里出了问题。有没有人可以获得战利品?

我尝试的第一种方法是使用以下代码:

install.packages("/Users/Natsume/Downloads/R packages/PerformanceAnalytics_1.4.4000.tar.gz", repos = NULL, type="source")

我收到以下错误消息:

* installing *source* package ‘PerformanceAnalytics’ ...
** libs
gfortran-4.8  -fPIC -Wall -g -O2  -c  momentF.f90 -o momentF.o
make: gfortran-4.8: No such file or directory
make: *** [momentF.o] Error 1
ERROR: compilation failed for package ‘PerformanceAnalytics’
* removing ‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library/PerformanceAnalytics’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library/PerformanceAnalytics’
Warning in install.packages :
  installation of package ‘/Users/Natsume/Downloads/R packages/PerformanceAnalytics_1.4.4000.tar.gz’ had non-zero exit status

我尝试的第二种方法是完全遵循@ GSee的方法,但是当我运行以下代码时出错:

R --vanilla CMD INSTALL --build returnanalytics/pkg/PerformanceAnalyt 

以下是错误消息:

* installing to library ‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library’
* installing *source* package ‘PerformanceAnalytics’ ...
** libs
gfortran-4.8  -fPIC -Wall -g -O2  -c  momentF.f90 -o momentF.o
make: gfortran-4.8: No such file or directory
make: *** [momentF.o] Error 1
ERROR: compilation failed for package ‘PerformanceAnalytics’
* removing ‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library/PerformanceAnalytics’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library/PerformanceAnalytics’

1 个答案:

答案 0 :(得分:0)

感谢@ Dirk Eddelbuettel,@ Joshua Ulrich,@ Rhertel的回复。

我尝试了很多东西,其中一些并没有完全通过。我不确定哪一个有效。但这就是我所做的:

  • 运行这两行

curl -O http://r.research.att.com/libs/gfortran-4.8.2-darwin13.tar.bz2
 sudo tar fvxz gfortran-4.8.2-darwin13.tar.bz2 -C /

  • 但是,我记得此时我能够安装PerformanceAnalyticslibrary(PerformanceAnalytics)导致错误。我不确定我的mac是否成功完成了这两行。所以,我从其他地方下载了gfortran4.8。

  • here

  • 安装gfortran4.8
  • here
  • 安装gfortran 5
  • 然而,事情仍然不对。我猜想也许我应该卸载gfortran4.8,所以我运行了以下代码:sudo rm -r /usr/local/gfortran /usr/local/bin/gfortran
不知何故,它似​​乎有效。但显然我不知道究竟是什么帮助我设法install.packages + type="source"完成了PerformanceAnalytics包。此外,它产生了很多警告如下:

> install.packages("/Users/Natsume/Downloads/R packages/PerformanceAnalytics_1.4.4000.tar.gz", repos = NULL, type="source")
* installing *source* package ‘PerformanceAnalytics’ ...
** libs
gfortran-4.8  -fPIC -Wall -g -O2  -c  momentF.f90 -o momentF.o
gfortran-4.8: warning: couldn’t understand kern.osversion ‘15.4.0
momentF.f90:2.1:

 subroutine asVecCov1(ia, n, oa)
 1
Warning: Nonconforming tab character at (1)
momentF.f90:8.1:

 implicit none
 1
Warning: Nonconforming tab character at (1)
momentF.f90:11.1:

 integer :: n
 1
Warning: Nonconforming tab character at (1)
momentF.f90:12.1:

 double precision :: ia(n), oa(n*n)
 1
Warning: Nonconforming tab character at (1)
momentF.f90:15.1:

 integer :: i, j, ii
 1
Warning: Nonconforming tab character at (1)
momentF.f90:20.1:

 ii = 1
 1
Warning: Nonconforming tab character at (1)
momentF.f90:21.1:

 do j=1,n
 1
Warning: Nonconforming tab character at (1)
momentF.f90:22.1:

  do i=1,n
 1
Warning: Nonconforming tab character at (1)
momentF.f90:23.1:

   oa(ii) = ia(i) * ia(j)
 1
Warning: Nonconforming tab character at (1)
momentF.f90:24.1:

   ii = ii + 1
 1
Warning: Nonconforming tab character at (1)
momentF.f90:25.1:

  end do
 1
Warning: Nonconforming tab character at (1)
momentF.f90:26.1:

 end do
 1
Warning: Nonconforming tab character at (1)
momentF.f90:28.1:

 end subroutine asVecCov1
 1
Warning: Nonconforming tab character at (1)
momentF.f90:30.1:

 subroutine asVec(im, nr, nc, oa)
 1
Warning: Nonconforming tab character at (1)
momentF.f90:38.1:

 implicit none
 1
Warning: Nonconforming tab character at (1)
momentF.f90:41.1:

 integer :: nr, nc
 1
Warning: Nonconforming tab character at (1)
momentF.f90:42.1:

 double precision :: im(nr,nc), oa(nr * nc)
 1
Warning: Nonconforming tab character at (1)
momentF.f90:45.1:

 integer :: i, j
 1
Warning: Nonconforming tab character at (1)
momentF.f90:50.1:

 do j=1,nc
 1
Warning: Nonconforming tab character at (1)
momentF.f90:51.1:

  do i=1,nr
 1
Warning: Nonconforming tab character at (1)
momentF.f90:52.1:

   oa(i + (j-1) * nr) = im(i,j)
 1
Warning: Nonconforming tab character at (1)
momentF.f90:53.1:

  end do
 1
Warning: Nonconforming tab character at (1)
momentF.f90:54.1:

 end do
 1
Warning: Nonconforming tab character at (1)
momentF.f90:56.1:

 end subroutine asVec
 1
Warning: Nonconforming tab character at (1)
momentF.f90:58.1:

 subroutine M3(x, mu, nr, nc, C, om)
 1
Warning: Nonconforming tab character at (1)
momentF.f90:68.1:

 implicit none
 1
Warning: Nonconforming tab character at (1)
momentF.f90:71.1:

 integer :: nr, nc
 1
Warning: Nonconforming tab character at (1)
momentF.f90:72.1:

 double precision :: x(nr, nc), mu(nc), om(nc, nc*nc), C(nc*nc, nc)
 1
Warning: Nonconforming tab character at (1)
momentF.f90:75.1:

 integer :: i
 1
Warning: Nonconforming tab character at (1)
momentF.f90:76.1:

 double precision :: alpha, beta
 1
Warning: Nonconforming tab character at (1)
momentF.f90:77.1:

 double precision :: centret(nc), tccr(nc * nc)
 1
Warning: Nonconforming tab character at (1)
momentF.f90:79.1:

 alpha = 1.d0
 1
Warning: Nonconforming tab character at (1)
momentF.f90:80.1:

 beta = 1.d0
 1
Warning: Nonconforming tab character at (1)
momentF.f90:82.1:

 do i=1,nr
 1
Warning: Nonconforming tab character at (1)
momentF.f90:83.1:

  centret = x(i,:) - mu
 1
Warning: Nonconforming tab character at (1)
momentF.f90:86.1:

  call asVecCov1(centret, nc, tccr)
 1
Warning: Nonconforming tab character at (1)
momentF.f90:94.1:

  call DGEMM('N', 'N', nc*nc, nc, 1, alpha, tccr, nc*nc, centret, 1, beta, C, n
 1
Warning: Nonconforming tab character at (1)
momentF.f90:95.1:

 end do
 1
Warning: Nonconforming tab character at (1)
momentF.f90:97.1:

 om = transpose(C) / DBLE(nr)
 1
Warning: Nonconforming tab character at (1)
momentF.f90:120.1:

 end subroutine M3
 1
Warning: Nonconforming tab character at (1)
momentF.f90:122.1:

 subroutine M4(x, mu, nr, nc, D, om)
 1
Warning: Nonconforming tab character at (1)
momentF.f90:132.1:

 implicit none
 1
Warning: Nonconforming tab character at (1)
momentF.f90:135.1:

 integer :: nr, nc
 1
Warning: Nonconforming tab character at (1)
momentF.f90:136.1:

 double precision :: x(nr, nc), mu(nc), om(nc, nc*nc*nc), D(nc*nc*nc, nc)
 1
Warning: Nonconforming tab character at (1)
momentF.f90:139.1:

 integer :: i
 1
Warning: Nonconforming tab character at (1)
momentF.f90:140.1:

 double precision :: alpha, beta, beta1
 1
Warning: Nonconforming tab character at (1)
momentF.f90:141.1:

 double precision :: centret(nc), tccr(nc * nc), tccr2(nc * nc * nc), C(nc*nc, 
 1
Warning: Nonconforming tab character at (1)
momentF.f90:143.1:

 alpha = 1.d0
 1
Warning: Nonconforming tab character at (1)
momentF.f90:144.1:

 beta = 0.d0
 1
Warning: Nonconforming tab character at (1)
momentF.f90:145.1:

 beta1 = 1.d0
 1
Warning: Nonconforming tab character at (1)
momentF.f90:147.1:

 do i=1,nr
 1
Warning: Nonconforming tab character at (1)
momentF.f90:148.1:

  centret = x(i,:) - mu
 1
Warning: Nonconforming tab character at (1)
momentF.f90:152.1:

  call asVecCov1(centret, nc, tccr)
 1
Warning: Nonconforming tab character at (1)
momentF.f90:159.1:

  call asVec(C, nc*nc, nc, tccr2)
 1
Warning: Nonconforming tab character at (1)
momentF.f90:162.1:

  call DGEMM('N', 'N', nc*nc*nc, nc, 1, alpha, tccr2, nc*nc*nc, centret, 1, bet
 1
Warning: Nonconforming tab character at (1)
momentF.f90:163.1:

 end do
 1
Warning: Nonconforming tab character at (1)
momentF.f90:165.1:

 om = transpose(D) / DBLE(nr)
 1
Warning: Nonconforming tab character at (1)
momentF.f90:188.1:

 end subroutine M4
 1
Warning: Nonconforming tab character at (1)
gfortran-4.8 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o PerformanceAnalytics.so momentF.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2 -lgfortran -lquadmath -lm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
gfortran-4.8: warning: couldn’t understand kern.osversion ‘15.4.0
ld: warning: object file (momentF.o) was built for newer OSX version (10.11) than being linked (10.4)
installing to /Library/Frameworks/R.framework/Versions/3.2/Resources/library/PerformanceAnalytics/libs
** R
** data
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (PerformanceAnalytics)