ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 25 Jul 2012 17:14:09 -0500Can't Access Functions After Install R Additional Packagehttps://ask.sagemath.org/question/9183/cant-access-functions-after-install-r-additional-package/Hi,
I'm trying to install an additional package for R, "SampleSizeMeans."
In the Notebook, I type r.install_packages('SampleSizeMeans') and it seems to install properly (output pasted below). Note I do this with "Sage" as the worksheet type at the top.
I've quit Sage completely and restarted the notebook, but none of the functions are available. I switch the Type in the Sage notebook to "R" and type "mu.acc(len=0.2, alpha=2, beta=2, n0=10)" (one of the examples) but it says "Error: could not find function "mu.acc".
Am I missing something or is this a bug?
Thanks very much,
Justin
0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata
2528maxresident)k
0inputs+0outputs (0major+204minor)pagefaults 0swaps
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-unknown-linux-gnu (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.
Natural language support but running in an English locale
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.
> options(repos="http://cran.r-project.org/");
install.packages("SampleSizeMeans")
trying URL
'http://cran.r-project.org/src/contrib/SampleSizeMeans_1.0.tar.gz'
Content type 'application/x-gzip' length 14807 bytes (14 Kb)
opened URL
==================================================
downloaded 14 Kb
* installing *source* package SampleSizeMeans ...
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices ...
** testing if installed package can be loaded
* DONE (SampleSizeMeans)
The downloaded packages are in
/tmp/RtmpG4jlho/downloaded_packages
>
Please restart Sage in order to use 'SampleSizeMeans'.
Wed, 25 Jul 2012 14:07:20 -0500https://ask.sagemath.org/question/9183/cant-access-functions-after-install-r-additional-package/Comment by kcrisman for <p>Hi, </p>
<p>I'm trying to install an additional package for R, "SampleSizeMeans."
In the Notebook, I type r.install_packages('SampleSizeMeans') and it seems to install properly (output pasted below). Note I do this with "Sage" as the worksheet type at the top. </p>
<p>I've quit Sage completely and restarted the notebook, but none of the functions are available. I switch the Type in the Sage notebook to "R" and type "mu.acc(len=0.2, alpha=2, beta=2, n0=10)" (one of the examples) but it says "Error: could not find function "mu.acc". </p>
<p>Am I missing something or is this a bug?</p>
<p>Thanks very much,</p>
<p>Justin</p>
<p>0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata
2528maxresident)k
0inputs+0outputs (0major+204minor)pagefaults 0swaps</p>
<p>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-unknown-linux-gnu (64-bit)</p>
<p>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.</p>
<p>Natural language support but running in an English locale</p>
<p>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.</p>
<p>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.</p>
<blockquote>
<p>options(repos="http://cran.r-project.org/");
install.packages("SampleSizeMeans")
trying URL
'http://cran.r-project.org/src/contrib/SampleSizeMeans_1.0.tar.gz'
Content type 'application/x-gzip' length 14807 bytes (14 Kb)</p>
<h1>opened URL</h1>
</blockquote>
<p>downloaded 14 Kb</p>
<ul>
<li><p>installing <em>source</em> package SampleSizeMeans ...
<em>* R
*</em> preparing package for lazy loading
<em>* help
*</em>* installing help indices
<em>* building package indices ...
*</em> testing if installed package can be loaded</p></li>
<li><p>DONE (SampleSizeMeans)</p></li>
</ul>
<p>The downloaded packages are in
/tmp/RtmpG4jlho/downloaded_packages</p>
<blockquote>
<p>Please restart Sage in order to use 'SampleSizeMeans'.</p>
</blockquote>
https://ask.sagemath.org/question/9183/cant-access-functions-after-install-r-additional-package/?comment=19337#post-id-19337You figured this out, but loading a library should also be necessary for R packages within a standard (non-Sage) R session - just for those who find this later. I don't think there is any way around this.Wed, 25 Jul 2012 17:14:09 -0500https://ask.sagemath.org/question/9183/cant-access-functions-after-install-r-additional-package/?comment=19337#post-id-19337Answer by Justin1 for <p>Hi, </p>
<p>I'm trying to install an additional package for R, "SampleSizeMeans."
In the Notebook, I type r.install_packages('SampleSizeMeans') and it seems to install properly (output pasted below). Note I do this with "Sage" as the worksheet type at the top. </p>
<p>I've quit Sage completely and restarted the notebook, but none of the functions are available. I switch the Type in the Sage notebook to "R" and type "mu.acc(len=0.2, alpha=2, beta=2, n0=10)" (one of the examples) but it says "Error: could not find function "mu.acc". </p>
<p>Am I missing something or is this a bug?</p>
<p>Thanks very much,</p>
<p>Justin</p>
<p>0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata
2528maxresident)k
0inputs+0outputs (0major+204minor)pagefaults 0swaps</p>
<p>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-unknown-linux-gnu (64-bit)</p>
<p>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.</p>
<p>Natural language support but running in an English locale</p>
<p>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.</p>
<p>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.</p>
<blockquote>
<p>options(repos="http://cran.r-project.org/");
install.packages("SampleSizeMeans")
trying URL
'http://cran.r-project.org/src/contrib/SampleSizeMeans_1.0.tar.gz'
Content type 'application/x-gzip' length 14807 bytes (14 Kb)</p>
<h1>opened URL</h1>
</blockquote>
<p>downloaded 14 Kb</p>
<ul>
<li><p>installing <em>source</em> package SampleSizeMeans ...
<em>* R
*</em> preparing package for lazy loading
<em>* help
*</em>* installing help indices
<em>* building package indices ...
*</em> testing if installed package can be loaded</p></li>
<li><p>DONE (SampleSizeMeans)</p></li>
</ul>
<p>The downloaded packages are in
/tmp/RtmpG4jlho/downloaded_packages</p>
<blockquote>
<p>Please restart Sage in order to use 'SampleSizeMeans'.</p>
</blockquote>
https://ask.sagemath.org/question/9183/cant-access-functions-after-install-r-additional-package/?answer=13856#post-id-13856Turns out the step I was missing is that you must load the library using the r function r.library (i.e., r.library('SampleSizeMeans').
Therefore, step-by-step for loading and then using new R packages:
1. Use `r.install_packages('PackageName')`
2. Restart Sage
3. Use `r.library('PackageName')` to load the package prior to use.
It's worth noting that although it recommends that you restart Sage, it seemed to work immediately for the packages I tried so it may not be strictly necessary which is very handy!Wed, 25 Jul 2012 15:17:13 -0500https://ask.sagemath.org/question/9183/cant-access-functions-after-install-r-additional-package/?answer=13856#post-id-13856Comment by kcrisman for <p>Turns out the step I was missing is that you must load the library using the r function r.library (i.e., r.library('SampleSizeMeans'). </p>
<p>Therefore, step-by-step for loading and then using new R packages:</p>
<ol>
<li>Use <code>r.install_packages('PackageName')</code></li>
<li>Restart Sage</li>
<li>Use <code>r.library('PackageName')</code> to load the package prior to use. </li>
</ol>
<p>It's worth noting that although it recommends that you restart Sage, it seemed to work immediately for the packages I tried so it may not be strictly necessary which is very handy!</p>
https://ask.sagemath.org/question/9183/cant-access-functions-after-install-r-additional-package/?comment=19338#post-id-19338No, it's almost certainly not necessary to restart Sage; we really have to change that piece of doc, I've never needed to.Wed, 25 Jul 2012 17:12:14 -0500https://ask.sagemath.org/question/9183/cant-access-functions-after-install-r-additional-package/?comment=19338#post-id-19338