[R] Tool for update

Andy Bunn abunn at whrc.org
Fri Apr 22 19:52:27 CEST 2005


Hi Ronaldo: First, this script was discussed a few days ago. Note that under
2.1 update.packages() has changed for the better. Look at the NEWS file.

So, if you want to keep updating on Tuesdays, despite sensible advice to the
contrary offered in this thread

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/48390.html

you'll have to change the script to something like this:

# 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"))
    {
        cat("This can take a few seconds...\n")
        update.packages(ask=FALSE)
   }
}


Second, you wrote:

> I make a little adapt to this script and try to use.
>
> But, when a file dont exist, the installation is aborted.

If you really need to automate this and use download.file then look at using
try() to catch errors. I suggest you look at the file structure of the
src/contrib folder at CRAN and modify your code if you need to. For
instance, point to src/contrib/assist_1.0.tar.gz and not assist_0.1.2.tar.gz
as the source version is now 1.0 for assist.

But, as mentioned earlier, it would be better to move this all to a chron
job.

HTH, Andy




More information about the R-help mailing list