Ask Your Question
0

Can't Access Functions After Install R Additional Package

asked 2012-07-25 21:07:20 +0200

Justin1 gravatar image

updated 2012-07-26 00:14:15 +0200

kcrisman gravatar image

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'.

edit retag flag offensive close merge delete

Comments

You 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.

kcrisman gravatar imagekcrisman ( 2012-07-26 00:14:09 +0200 )edit

1 Answer

Sort by » oldest newest most voted
2

answered 2012-07-25 22:17:13 +0200

Justin1 gravatar image

updated 2012-07-26 00:13:06 +0200

kcrisman gravatar image

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').

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!

edit flag offensive delete link more

Comments

No, it's almost certainly not necessary to restart Sage; we really have to change that piece of doc, I've never needed to.

kcrisman gravatar imagekcrisman ( 2012-07-26 00:12:14 +0200 )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-07-25 21:07:20 +0200

Seen: 1,786 times

Last updated: Jul 26 '12