z/OS Tools & Language

Expand all | Collapse all

How to install R packages?

  • 1.  How to install R packages?

    Posted 01-24-2017 01:29

    Hello,

    I’d like to install R packages I got from CRAN repository, for example, RJDBC.

    First, I tried to install rJava package because it is required for RJDBC.

    I get rJava_0.9-8.tar.gz from CRAN site and upload to z/OS USS.
    https://cran.r-project.org/web/packages/rJava/index.html

    And then I issued install command but failed.

    $ R -e 'install.packages(c("rJava_0.9-8.tar.gz"), repos = NULL, type="source")'
    
    R version 3.3.2 (2016-10-31) -- "Sincere Pumpkin Patch"
    Copyright (C) 2016 The R Foundation for Statistical Computing
    Platform: i370-ibm-openedition (64-bit)
    
    R is free software and comes with ABSOLUTELY NO WARRANTY.
    You are welcome to redistribute it under certain conditions.
    Type 'license()' or 'licence()' for distribution details.
    
    R is a collaborative project with many contributors.
    Type 'contributors()' for more information and
    'citation()' on how to cite R or R packages in publications.
    
    Type 'demo()' for some demos, 'help()' for on-line help, or
    'help.start()' for an HTML browser interface to help.
    Type 'q()' to quit R.
    
    > install.packages(c("rJava_0.9-8.tar.gz"), repos = NULL, type="source")
    Warning in strptime(xx, f <- "%Y-%m-%d %H:%M:%OS", tz = tz) :
      unknown timezone '' (open failed for "/usr/lpp/R332/R/lib/R/share/zoneinfo/UTC0")
    * installing *source* package 'rJava' ...
    ** package 'rJava' successfully unpacked and MD5 sums checked
    trap: ./configure 1956: FSUM7327 signal number 13 not conventional
    checking for gcc... /u/pdharr/Rnew/devel-dist/bin/xlc_echocmd
    checking whether the C compiler works... no
    configure: error: in `/ZOS1/tmp/Rtmp3I0Jcq/R.INSTALL401004b63ac4b77/rJava':
    configure: error: C compiler cannot create executables
    See `config.log' for more details
    ERROR: configuration failed for package 'rJava'
    * removing '/V1R11/usr/lpp/R332/R/lib/R/library/rJava'
    Warning message:
    In install.packages(c("rJava_0.9-8.tar.gz"), repos = NULL, type = "source") :
      installation of package 'rJava_0.9-8.tar.gz' had non-zero exit status
    >
    

    I unpacked python-r-devel in /usr/lpp/R332/python-devel and I set environment variables in .profile

    # env for python-devel
    export BD=/usr/lpp/R332/python-devel
    export PATH=$BD/bin:$PATH
    export LIBPATH=$BD/lib:$LIBPATH
    export PKG_CONFIG_PATH=$BD/lib/pkgconfig:$BD/share/pkgconfig
    export CURL_CA_BUNDLE=$BD/etc/ssl/cacert.pem
    export FFI_LIB=$BD/lib/ffi
    export X11_DIST=$BD
    export DEVEL_DIST=$BD
    
    # env for R332
    export _BPXK_AUTOCVT=ON
    export BASE=/usr/lpp/R332/R
    export PATH=$BASE/bin:$PATH
    export LIBPATH=$BASE/lib:$LIBPATH
    export PKG_CONFIG_PATH=$BASE/lib/pkgconfig:$PKG_CONFIG_PATH
    export TZDIR=$BASE/lib/R/share/zoneinfo
    export RHOME=$BASE/lib/R
    export R_DIST=$BASE
    

    How can I insatall R packages?

    regards.
    Tomohiro Taguchi



  • 2.  RE: How to install R packages?

    Posted 01-24-2017 17:39

    Hello Tomohiro,

    It might be difficult to get everything working that you will need to install R packages that include C or C++ code. But le us see how far we can get.

    Can you please send us the file config.log?

    thanks,

    Rick Harris
    Rocket Software.



  • 3.  RE: How to install R packages?

    Posted 01-25-2017 22:46

    Hello,

    It seems that config.log file was created in /tmp directory, such as /tmp/Rtmp3I0Jcq/…, but this directory was removed after package install command.
    Do you have any idea for checking config.log file?

    regards.
    Tomohiro Taguchi



  • 4.  RE: How to install R packages?

    Posted 01-26-2017 00:11

    Hello,
    I predict a series of little problems. I will certainly port this module
    sometime in the next week or three, if you would prefer to wait.

    Anyway here is a useful bit of R code:
    all_packages <- c(“rJava”)
    uninstalled_packages <- setdiff(all_packages,
    rownames(installed.packages()))
    if (length(uninstalled_packages) > 0) {
    install.packages(uninstalled_packages, type = “source”, repos=“
    http://cran.rstudio.com/”,
    destdir="/u/pdharr/Rnew/downloads", INSTALL_opts="–verbose
    –no-clean-on-error")
    }

    regards,
    Rick Harris



  • 5.  RE: How to install R packages?

    Posted 01-26-2017 01:11

    Hello,
    Thank you for your support.

    I tried install with --no-clean-on-error option like following but it seems config.log was removed.

    install.packages(c("rJava_0.9-8.tar.gz"), repos = NULL, type="source", destdir="/u/cics004/R/package/dest",INSTALL_opts="--verbose --no-clean-on-error")

    (I couldn’t find config.log even though I issued “find / -name config.log” command.)

    And our z/OS environment can not access external web sites directly such as http://cran.rstudio.com, so I have to download files by PC and transfer them to z/OS.

    I’m looking forward your updates!

    regards.
    Tomohiro Taguchi



  • 6.  RE: How to install R packages?

    Posted 02-26-2017 22:45

    Hello,
    Do you have any updates?

    regards.
    Tomohiro Taguchi