0

I tried to install the latest version of PerformanceAnalytics using two methods suggested in a well answered question by @GSee and @hadley.

I have no idea where went wrong. Could anyone have a loot at it?

The first method I tried is using the following code:

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

I got the following error message:

* 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

The second method I tried is following @GSee's method exactly, but error occured when I ran the following code:

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

Here is the error message:

* 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’
Community
  • 1
  • 1
Daniel
  • 1,428
  • 3
  • 16
  • 35
  • The error seems to be unrelated to the package. Apparently the system does not find the fortran compiler. If you are using a Linux system, you could try to install the compiler with `sudo apt-get install gfortran-4.8` and see if the problem persists. – RHertel Apr 09 '16 at 10:10
  • 1
    You need to be able to install compiled code from source. See [Section 6.3.2 OS X in R Installation and Administration](https://cran.r-project.org/doc/manuals/r-release/R-admin.html#OS-X-packages) and [Appendix C.3](https://cran.r-project.org/doc/manuals/r-release/R-admin.html#OS-X). I don't use a Mac, so I'm not much help beyond pointing to the relevant docs... – Joshua Ulrich Apr 09 '16 at 12:10
  • We recently added / expanded entries in the [Rcpp FAQ](https://cloud.r-project.org/web/packages/Rcpp/vignettes/Rcpp-FAQ.pdf) that deal with the same issue -- one needs `gfortran` to use RcppArmadillo and its LAPACK libraries for linking (even though we don't directly include Fortran). The toolchain is the same so these two entries and links there should help you. – Dirk Eddelbuettel Apr 09 '16 at 15:00
  • Thank you all for your helpful replies. I don't know how I got it done, so I wrote down what I did in my answer below. – Daniel Apr 10 '16 at 09:16

1 Answers1

0

Thanks @ Dirk Eddelbuettel, @Joshua Ulrich, @RHertel for your helpful replies.

I tried a bunch of things, some of them did not go through completely. I am not sure which one worked. but this is what I did:

  • run these two lines

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 /

  • However, I remembered at this point I was able to install PerformanceAnalytics but library(PerformanceAnalytics) caused errors. And I am not sure my mac successfully ran through those two lines. So, I went to download gfortran4.8 from elsewhere.

  • install gfortran4.8 from here

  • install gfortran 5 from here
  • However, something was still not right. I guessed maybe I should uninstall gfortran4.8, so I ran the following code: sudo rm -r /usr/local/gfortran /usr/local/bin/gfortran

somehow, it seemed working. But apparently I have no idea which exactly helped me managed to get install.packages + type="source" on PerformanceAnalytics package done. Also, it produced a lot of warnings as follows:

> 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)
Daniel
  • 1,428
  • 3
  • 16
  • 35