Thank you very much for the reply Henrik, you gave great pointers for me to
look at.

I am now curious about R.cache (although I am not sure it will help in my
case, I'll need to look at it further).

Also, I was debating if to use R-help or R-devel for this, since I was not
sure from the description text <http://www.r-project.org/mail.html>if it is
intended for developing R (as in "R base"), or R package development in
general (well, now I know).

With regards,
Tal





----------------Contact
Details:-------------------------------------------------------
Contact me: Tal.Galili@gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
----------------------------------------------------------------------------------------------



On Wed, Apr 9, 2014 at 7:41 PM, Henrik Bengtsson <hb@biostat.ucsf.edu>wrote:

> [Sounds like a question for R-devel]
>
> On Wed, Apr 9, 2014 at 5:02 AM, Tal Galili <tal.galili@gmail.com> wrote:
> > Hello all,
> >
> >
> > I wish to add to the
> > installr<http://cran.r-project.org/web/packages/installr/>package the
> > ability to check for new versions of R once every X units of
> > time (maybe once every two weeks).
> >
> > I would like to keep a time stamp somewhere, that would stay persistent
> > across R sessions (i.e.: that if I turn R off and then back on, it would
> > keep track of the last time it checked for a new R version).
> > It would be best if I could save some file, maybe in the installr package
> > folder, that would keep track of that.
> >
> > Any suggestions or "best practice" on how to implement something like
> that?
>
> I'm not aware of any standards for where to store site- and/or
> user-specific R settings that are persistent across session.  It would
> certainly nice to have a standard, instead of everyone inventing their
> own.
>
> Either way, before starting it is useful (even if you don't distribute
> via CRAN) if you're aware of the following passage from
> http://cran.r-project.org/web/packages/policies.html provides a fair
> guideline:
>
> "- Packages should not write in the users’ home filespace, nor
> anywhere else on the file system apart from the R session’s temporary
> directory (or during installation in the location pointed to by
> TMPDIR: and such usage should be cleaned up). Installing into the
> system’s R installation (e.g., scripts to its bin directory) is not
> allowed.
> Limited exceptions may be allowed in interactive sessions if the
> package obtains confirmation from the user."
>
> Then have a look the R.cache package.  It is used for caching objects
> to file, e.g. memoization of computational expensive results.  It
> addresses the above policy in the following way:
>
> 1. It checks whether ~/.Rcache/ exists or not.  If it exists, it is
> assumed that it already has the user's permission.
>
> 2  Otherwise, if in an interactive R session, it asks the user for
> permission to create that directory.  If successful it is created (and
> it drops an informative README.txt file in there too), otherwise it
> uses a temporary directory.
>
> Here is what it looks like to first time you load R.cache:
>
> > library(R.cache)
> The R.cache package needs to create a directory that will hold cache
> files. It is convenient to use one in the user's home directory,
> because it remains also after restarting R. Do you wish to create the
> '~/.Rcache/' directory? If not, a temporary directory
> (C:\Users\hb\AppData\Local\Temp\Rtmp61upx7/.Rcache) that is specific
> to this R session will be used. [Y/n]:
>
> You can use a similar strategy.  You could also use R.cache for you
> own purposes, e.g.
>
> readURL <- function(url, maxAge=10*24*3600, force=FALSE, ...) {
>   library("R.cache")
>   dirs <- "installr"  # => Caching to ~/.Rcache/installr/
>   key <- list(method="readURL", url=url)
>
>   # Check for cached results
>   bfr <- loadCache(key=key, dirs=dirs)
>   when <- attr(bfr, "when")
>
>   # Recent enough results already available?
>   if (!force && !is.null(when) && (Sys.time()-maxAge <= when))
>     return(bfr);
>
>   # Download and memoize
>   bfr <- readLines(url)
>   attr(bfr, "when") <- Sys.time()
>   saveCache(bfr, key=key, dirs=dirs)
>
>   bfr
> } # readURL()
>
> That would memoize the results from CRAN (for 10 days by default); you
> can of course cache the parsed R version etc, but I leave that to you.
>
> /Henrik
> (author of R.cache)
>
> >
> > Thanks,
> > Tal
> >
> >
> >
> >
> >
> > ----------------Contact
> > Details:-------------------------------------------------------
> > Contact me: Tal.Galili@gmail.com |
> > Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
> > www.r-statistics.com (English)
> >
> ----------------------------------------------------------------------------------------------
> >
> >         [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > 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.
>

	[[alternative HTML version deleted]]


