You might want to look at the new tools in 2.1.0alpha for this sort of thing. In particular, packageStatus() is now built on top of the new tools that it may be cleaner to call directly.

For what I understand you run this every time you use R on a Tuesday, which is not what I would want.

On Fri, 25 Mar 2005, abunn wrote:

I edited Rprofile to update everything on Tuesdays. I've been doing this
since 2.0 and I think I've had R running almost every Tuesday, which begs
the question of what I would be doing if R hadn't come into existence.

In any case, It works pretty well:

## This script gets all the packages I don't already have
# Run this once a week - say Tuesdays
if (interactive() ) { library(utils)}
is.tuesday <- as.POSIXlt(Sys.time())$wday == 2
if (is.tuesday == T)
{
   cat("Running a package check...\nOccurs once a week, on Tuesdays\n")
   cat("Upgrade existing packages and check for new packages (y/N)? ")
   check.new <- as.character(readLines(n = 1))
   if (any(check.new == "y", check.new == "Y"))
   {
       options(CRAN = "http://cran.us.r-project.org/";)
       cat("This can take a few seconds...\n")
       x <- packageStatus(repositories = getOption("repositories")()[[1]])
       print(x)
       install.packages(x$avail$Package[x$avail$Status == "not installed"])
       cat("Upgrading to new versions if available\n")
       upgrade(x)
  }
}


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Thomas Lumley
Sent: Thursday, March 24, 2005 4:03 PM
To: Darren Weber
Cc: [email protected]; [EMAIL PROTECTED]
Subject: Re: [R] Tool for update


On Thu, 24 Mar 2005, Darren Weber wrote:

Is there a way to set a cron job to automatically update packages?
Maybe something like this:

$unixprompt> R --vanilla update.packages()


If you put update.packages(repos="http://cran.us.r-project.org";, ask=FALSE)

in a file update.R you can do
   R CMD BATCH update.R update.log
or even fancier, something like
   R CMD BATCH update.R update-`date --iso-8601`.log

to keep dated log files.

        -thomas

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html


______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


-- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to