Dear all,
When one tries to load a non-installed package you get the error:
Error in library(xyz) : there is no package called 'xyz'
I noticed on several occasions that this puzzles beginners. Therefore I suggest
to change the error description in:
Error in library(xyz) : there is no package called 'xyz' installed on
this machine. Check the name of the package or use
install.packages("xyz") to install it.
Best regards,
Thierry
----------------------------------------------------------------------------
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium
Research Institute for Nature and Forest
team Biometrics & Quality Assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
Thierry.Onkelinx at inbo.be
www.inbo.be
To call in the statistician after the experiment is done may be no more than
asking him to perform a post-mortem examination: he may be able to say what the
experiment died of.
~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data.
~ Roger Brinner
The combination of some data and an aching desire for an answer does not ensure
that a reasonable answer can be extracted from a given body of data.
~ John Tukey
Le mercredi 26 octobre 2011 ? 09:46 +0000, ONKELINX, Thierry a ?crit :> Dear all, > > When one tries to load a non-installed package you get the error: > > Error in library(xyz) : there is no package called 'xyz' > > I noticed on several occasions that this puzzles beginners. Therefore > I suggest to change the error description in: > > Error in library(xyz) : there is no package called 'xyz' installed on > this machine. Check the name of the package or use > install.packages("xyz") to install it.Couldn't R even directly ask for installing if it exists on CRAN? Like: Error in library(xyz) : package 'xyz' is not installed on this machine. Do you want to install it? [Y/n] Regards
Thierry,
I agree with you and think that computers _should_ help users.
When R tells me a package does not exist, it is almost never because I
typed an incorrect package name.
Almost always it is because:
(1) I am using an old script with a new version of R and have not yet
installed a package.
(2) I am running a current script on a different machine that does not have
a package installed.
(3) I am copying some code from the web and have not yet installed a
package.
MiKTeX does a nice job of auto-installing packages in a silent manner.
I've tried to imitate that with the function below. I add this to
.Rprofile. Then use "lib(pkg)" to install and attach packages
automatically. The function is rough and needs improvement, but works
reasonably well.
Kevin
assign("lib",
function(p=NULL, ...){
# Why ... ?
p <- substitute(p)
if(!is.null(p) & !is.character(p))
p <- deparse(substitute(p))
print(p)
ip <- rownames(installed.packages())
# Should be more clever here and only install some of 'p'
if(!(p %in% ip)) install.packages(p)
require(p, ..., character.only=TRUE)
}, env=startup)
On Wed, Oct 26, 2011 at 4:46 AM, ONKELINX, Thierry
<Thierry.ONKELINX@inbo.be> wrote:
> Dear all,
>
> When one tries to load a non-installed package you get the error:
>
> Error in library(xyz) : there is no package called 'xyz'
>
> I noticed on several occasions that this puzzles beginners. Therefore I
> suggest to change the error description in:
>
> Error in library(xyz) : there is no package called 'xyz' installed
on this
> machine. Check the name of the package or use
install.packages("xyz") to
> install it.
>
> Best regards,
>
> Thierry
>
>
>
----------------------------------------------------------------------------
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek
> team Biometrie & Kwaliteitszorg
> Gaverstraat 4
> 9500 Geraardsbergen
> Belgium
>
> Research Institute for Nature and Forest
> team Biometrics & Quality Assurance
> Gaverstraat 4
> 9500 Geraardsbergen
> Belgium
>
> tel. + 32 54/436 185
> Thierry.Onkelinx@inbo.be
> www.inbo.be
>
> To call in the statistician after the experiment is done may be no more
> than asking him to perform a post-mortem examination: he may be able to say
> what the experiment died of.
> ~ Sir Ronald Aylmer Fisher
>
> The plural of anecdote is not data.
> ~ Roger Brinner
>
> The combination of some data and an aching desire for an answer does not
> ensure that a reasonable answer can be extracted from a given body of data.
> ~ John Tukey
>
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
[[alternative HTML version deleted]]
On Wed, Oct 26, 2011 at 5:46 AM, ONKELINX, Thierry <Thierry.ONKELINX at inbo.be> wrote:> Dear all, > > When one tries to load a non-installed package you get the error: > > Error in library(xyz) : there is no package called 'xyz' > > I noticed on several occasions that this puzzles beginners. Therefore I suggest to change the error description in: > > Error in library(xyz) : there is no package called 'xyz' installed on this machine. Check the name of the package or use install.packages("xyz") to install it. > > Best regards, >Perhaps it could report where it looked and couldn't find it: There is no package called 'xyz' in "C:/R/win-library/2.13" and "C:/R/R-2.13.2/library" -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com
"BTW: an ever more intuitive solution (IMHO) would be to auto-complete package names in library( ... Deepayan?;) That is non-intrusive and in line with the general use of R." (Simon) This is indeed a long wanted feature and to my surprise it actually already exists!!! (seems that Deepayan did not tell anybody about it ;) ) The help page ?completion in the utils package explains how to enable it: utils::rc.settings(ipck=TRUE) It simply worked on my Ubuntu box -- and directly went in my .Rprofile :) Hope this helps. Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa