Ask Your Question
1

error in installing R packages

asked 2012-09-05 12:07:29 +0100

kd gravatar image

Hello,

Could anyone tell me how to install R packages in Sage? I fail it as follows:


$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.7.4
BuildVersion:   11E53 
$ hdiutil mount /Users/me/Downloads/sage-5.2-OSX-64bit-10.6-x86_64-Darwin.dmg
$ cp -R -P /Volumes/sage-5.2-OSX-64bit-10.6-x86_64-Darwin/sage /Applications
$ open /Applications/sage/sage
 :
 :
$ 
$ sage
----------------------------------------------------------------------
| Sage Version 5.2, Release Date: 2012-07-25                         |
| Type "notebook()" for the browser-based notebook interface.        |
| Type "help()" for help.                                            |
----------------------------------------------------------------------
sage: 
sage: quit
Exiting Sage (CPU time 0m0.05s, Wall time 0m6.00s).
$ 
$ sage -R
R version 2.14.0 (2011-10-31)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-apple-darwin10.8.0 (64-bit)
 :
 :
> install.packages('coda')
 :
 :
trying URL 'http://cran.ism.ac.jp/src/contrib/coda_0.15-2.tar.gz'
Content type 'application/x-gzip' length 73937 bytes (72 Kb)
opened URL
==================================================
downloaded 72 Kb

* installing *source* package ‘coda’ ...
** package 'coda' successfully unpacked and MD5 sums checked
** R
** data
** inst
** preparing package for lazy loading
Error in if (file.info(codeFile)["size"] == file.info(loaderFile)["size"]) warning("package seems to be using lazy loading already") else { : 
  missing value where TRUE/FALSE needed
ERROR: lazy loading failed for package ‘coda’
* removing ‘/Applications/sage/local/lib/R/library/coda’

The downloaded packages are in 
    ‘/private/var/folders/ch/p_433hf96vq2qm72w1gg3mmc0000gn/T/RtmpVPLwTU/downloaded_packages’ 
Warning message:
In install.packages("coda") :
   installation of package 'coda' had non-zero exit status 
> 
> q()
Save workspace image? [y/n/c]: n
$ 
$ sage -f r
Calling sage-spkg on 'r'
r-2.14.0.p3
====================================================
Extracting package /Applications/sage/spkg/standard/r-2.14.0.p3.spkg
-rw-r--r--@ 1 kkondo  admin  107  7 27 23:26 /Applications/sage/spkg/standard/r-2.14.0.p3.spkg
tar: Unrecognized archive format
tar: Error exit delayed from previous errors.
Error: failed to extract /Applications/sage/spkg/standard/r-2.14.0.p3.spkg
$ 
edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2012-09-05 13:41:00 +0100

kcrisman gravatar image
$ sage -f r
Calling sage-spkg on 'r'
r-2.14.0.p3

Oops! That is totally unrelated to installing R packages. You are trying there to reinstall the complete R installation inside of Sage.

I'm surprised that your initial method didn't work, but you should be able to try the following:

sage: r.install_packages("coda")
<various messages>
sage: r.library('coda')

to use it. There is a warning about restarting Sage, but this seems to be unnecessary in my experience.

edit flag offensive delete link more
0

answered 2012-09-05 22:20:59 +0100

KKondo gravatar image

Thank you for your answer. But it fails as follows:


$ sage
----------------------------------------------------------------------
| Sage Version 5.2, Release Date: 2012-07-25                         |
| Type "notebook()" for the browser-based notebook interface.        |
| Type "help()" for help.                                            |
----------------------------------------------------------------------
sage: 
sage: r.install_packages("coda")

R version 2.14.0 (2011-10-31)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-apple-darwin10.8.0 (64-bit)
 :
 :
> options(repos="http://cran.r-project.org/"); install.packages("coda")
trying URL 'http://cran.r-project.org/src/contrib/coda_0.15-2.tar.gz'
Content type 'application/x-gzip' length 73937 bytes (72 Kb)
opened URL
==================================================
downloaded 72 Kb

* installing *source* package ‘coda’ ...
** package 'coda' successfully unpacked and MD5 sums checked
** R
** data
** inst
** preparing package for lazy loading
Error in if (file.info(codeFile)["size"] == file.info(loaderFile)["size"]) warning("package seems to be using lazy loading already") else { : 
  missing value where TRUE/FALSE needed
ERROR: lazy loading failed for package ‘coda’
* removing ‘/Applications/sage/local/lib/R/library/coda’

The downloaded packages are in 
    ‘/private/var/folders/c7/qc6d0rs88xlbfy00r6by6by00000gn/T/Rtmp4MMxZq/downloaded_packages’ 
Warning message:
In install.packages("coda") :
   installation of package 'coda' had non-zero exit status 
> 

real    0m4.736s
user    0m1.791s
sys 0m0.137s
Please restart Sage in order to use 'coda'.
sage: quit
Exiting Sage (CPU time 0m0.63s, Wall time 0m10.44s).
$ ls  /Applications/sage/local/lib/R/library/ 
KernSmooth  cluster     graphics    nnet        stats4
MASS        codetools   grid        parallel    survival
Matrix      compiler    lattice     rpart       tcltk
base        datasets    methods     spatial     tools
boot        foreign     mgcv        splines     utils
class       grDevices   nlme        stats
$
$ sage
----------------------------------------------------------------------
| Sage Version 5.2, Release Date: 2012-07-25                         |
| Type "notebook()" for the browser-based notebook interface.        |
| Type "help()" for help.                                            |
----------------------------------------------------------------------
sage: 
sage: r.library('coda')
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
 :
 :
edit flag offensive delete link more

Comments

Hmm, the fact that this is the same error as before indicates to me something else is going on. Can you install any *other* R optional packages? Also, is it possible that you have some other R environment variables set? Sometimes that causes problems with "our" R.

kcrisman gravatar imagekcrisman ( 2012-09-05 22:25:18 +0100 )edit

Thank you for describing your consideration about this issue. I built the Sage source and found it worked fine when installing R packages.

KKondo gravatar imageKKondo ( 2012-09-12 01:30:56 +0100 )edit

Great! It would still be great to know what went wrong, so if it happens again, let us know and we can try to recreate it for debugging.

kcrisman gravatar imagekcrisman ( 2012-09-12 09:25:22 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-09-05 12:07:29 +0100

Seen: 2,182 times

Last updated: Sep 05 '12