3

Trying to install 'forecast' package in R version 3.3.2 on MacOS Sierra as follows:

install.packages("forecast")

Getting a slew of errors I don't understand. First it downloads all dependency packages from http://cloud.r-project.org. First error I get is this:

* installing *source* package ‘quadprog’ ...
** package ‘quadprog’ successfully unpacked and MD5 sums checked
** libs
gfortran -arch x86_64   -fPIC  -g -O2  -c aind.f -o aind.o
make: gfortran: No such file or directory
make: *** [aind.o] Error 1
ERROR: compilation failed for package ‘quadprog’
* removing ‘/Users/ekorne201/Library/R/3.3/library/quadprog’

It then moves on to:

* installing *source* package ‘fracdiff’ ...
** package ‘fracdiff’ successfully unpacked and MD5 sums checked

After which it says:

ld: warning: directory not found for option '-L/Users/Shared/Jenkins/workspace/External-R-3.3.2/vendor/build/lib'
ld: warning: directory not found for option '-L/usr/local/lib/gcc/i686-apple-darwin8/4.2.3/x86_64'
ld: warning: directory not found for option '-L/usr/local/lib/x86_64'
ld: warning: directory not found for option '-L/usr/local/lib/gcc/i686-apple-darwin8/4.2.3'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [fracdiff.so] Error 1
ERROR: compilation failed for package ‘fracdiff’
* removing ‘/Users/ekorne201/Library/R/3.3/library/fracdiff’

Goes through the same thing for 'lmtest' and 'RcppArmadillo', after which it ends with:

 ERROR: dependencies ‘tseries’, ‘fracdiff’, ‘lmtest’, ‘RcppArmadillo’ are not available for package ‘forecast’
    * removing ‘/Users/ekorne201/Library/R/3.3/library/forecast’

    The downloaded source packages are in
        ‘/private/var/folders/8p/54qnlb9x7bj8syz631_d58t92rmkyp/T/Rtmp246ipQ/downloaded_packages’
    Warning messages:
    1: In install.packages("forecast") :
      installation of package ‘quadprog’ had non-zero exit status
    2: In install.packages("forecast") :
      installation of package ‘fracdiff’ had non-zero exit status
    3: In install.packages("forecast") :
      installation of package ‘lmtest’ had non-zero exit status
    4: In install.packages("forecast") :
      installation of package ‘RcppArmadillo’ had non-zero exit status
    5: In install.packages("forecast") :
      installation of package ‘tseries’ had non-zero exit status
    6: In install.packages("forecast") :
      installation of package ‘forecast’ had non-zero exit status

Stuck on how to proceed and would appreciate the advice.

hhh
  • 50,788
  • 62
  • 179
  • 282
93i7hdjb
  • 1,136
  • 1
  • 9
  • 15
  • 1
    You need the gfortran library or whatever it is called for your OS. Maybe [this post](http://stackoverflow.com/questions/14222930/does-installing-gfortran-with-homebrew-and-with-an-installer-create-a-conflict) will be helpful. – lmo Mar 22 '17 at 18:23
  • thank you! FYI for all, did so here: https://cran.r-project.org/bin/macosx/tools/ – 93i7hdjb Mar 22 '17 at 18:36

1 Answers1

3

I got the same error. I solved it by installing the gfortran. In macOS, I can do it such that

brew install gcc 

and in R such that

install.packages("forecast")

so

> library(forecast); fit <- tbats(UScitiesD);
> fit
BATS(0.566, {0,2}, -, -)

Call: tbats(y = UScitiesD)

Parameters
  Lambda: 0.565592
  Alpha: 0.2166945
  MA coefficients: -0.130506 -0.511551

Seed States:
         [,1]
[1,] 90.10291
[2,]  0.00000
[3,]  0.00000

Sigma: 27.61468
AIC: 761.9238

As mentioned in comments, other method is to install it from here.

Related

  1. Does installing gfortran with homebrew and with an installer create a conflict?
hhh
  • 50,788
  • 62
  • 179
  • 282