On 20/08/2010 3:25 PM, Eva Nordstrom wrote:
I am using R 2.11.1 in a Microsoft Windows environment. Is there a way to load a
package (e.g. the zoo package) using only "written code", not menus or mouse
clicks?
The "code" below code brings up the "Select One" [package] menu. I just want to
automatically load the "zoo package".
local({pkg <- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE)
+ if(nchar(pkg)) library(pkg, character.only=TRUE)})
Simply say
library(zoo)
and it will be loaded, as long as you have it installed. If you don't
have it installed that will fail. In that case, first say
install.packages("zoo", dependencies=TRUE)
This might bring up a menu if you haven't already said which CRAN mirror
to use. To avoid that, first you should say
mirrors <- getCRANmirrors()
mirrors
Read the list, pick which one you like, then do
options(repos=mirrors[n, "URL"])
where n is the row number of the mirror you want. No menus!
Duncan Murdoch
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.