[Rd] 'library' or 'require' call to package which was already attached by Depends

2013-09-05 Thread alexios ghalanos
Hello,

I'm receiving the following NOTE during recent checks of the rmgarch
package:

'library' or 'require' call to 'rugarch' which was already attached by
Depends.

which I traced to the recent changes in R 3.02 Utilities:

 • packages which are used in ‘library()’ or ‘requires()’ calls in the R
code but were already put on the search path _via_ ‘Depends’.

However, the code uses the 'library()' call (of a package which is in
'Depends') inside the 'parallel::clusterEvalQ' function which is given
as an option to users for running certain routines in parallel.

Would it be possible to make allowances for this instance of the use of
'library()' or suggest a way to call 'clusterEvalQ' with 'library'
without triggering the NOTE?

Thanks,

Alexios

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Why does duplicate() make deep copies?

2013-09-05 Thread Simon Urbanek
On Sep 5, 2013, at 12:31 AM, Peter Meilstrup wrote:

> Some experimentation with the below function should convince you that the
> runtime of the bit inside sys.time is proportional to size*number*times. I
> think it should only be proportional to number*times. The function is only
> manipulating a list of references to vectors and not trying to make changes
> to the vectors themselves.
> 
> overcopying <- function(size, number, times) {
>  #Make a list of NUMBER vectors of SIZE, then reorder the list.  The
>  #vectors themselves are never touched, only their references are
>  #moved around.  If R implements "copy on write" correctly the
>  #elapsed time should be ~number*times.
>  L <- replicate(number, list(vector("numeric", size)), simplify=FALSE)
>  system.time(for (i in 1:times) {
>L[sample(number)] <- L
>  })
> }
> 
> I see that duplicate.c makes a recursive copy of each element when it
> encounters a VECSXP or a LISTSXP, which it seems there should be no need
> for (it should be sufficient to make a shallow copy and ensure NAMED is set
> on the elements.)
> 
> Why is R making apparently unnecessary deep copies?
> 

Because ref counting is not recursive. Changing that breaks a quite a few 
packages that abuse the fact that copies are currently deep. Main problem with 
that is that it's pretty much impossible to detect it ahead of time. That said, 
there are efforts underway by Luke Tierney and Michael Lawrence to see how far 
we can go without breaking everything.

Cheers,
Simon

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] libR.so: cannot open shared object file

2013-09-05 Thread gianluca.mastranto...@yahoo.it

First of all, thanks for your help.

I did all the things you told me. I was able to load the library, but then

Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared object 
'/lustre/work/gjona2/Wrap/BayesWrap/libs/BayesWrap.so':

  libR.so: cannot open shared object file: No such file or directory
In addition: Warning message:
package 'BayesWrap' was built under R version 2.15.2
Error: package/namespace load failed for 'BayesWrap'
Execution halted

what does it means?

G.M.

Il 04/09/13 22:42, Prof Brian Ripley ha scritto:

On 04/09/2013 19:58, Geoff Jentry wrote:

Can you add some details?
Suppose i have the package Model.tar.gz and my writable are is in
user/area, what i have to do next to install the package?


What I was picturing was something like this (forgive me if syntax isn't
100%):

mkdir user/area/myRLib
R CMD INSTALL --library=user/area/myRLib Model.tar.gz

and then in R:
library(Model, lib.loc="user/area/myRLib")

Note though Brian Ripley's response to me where he indicates that this
is handled automatically.


Yes,  install.packages("Model.tar.gz") should suffice.



-J

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel





__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Comments requested on "changedFiles" function

2013-09-05 Thread Duncan Murdoch

On 13-09-04 11:36 PM, Scott Kostyshak wrote:

On Wed, Sep 4, 2013 at 1:53 PM, Duncan Murdoch  wrote:

In a number of places internal to R, we need to know which files have
changed (e.g. after building a vignette).  I've just written a general
purpose function "changedFiles" that I'll probably commit to R-devel.
Comments on the design (or bug reports) would be appreciated.

The source for the function and the Rd page for it are inline below.


This looks like a useful function. Thanks for writing it. I have only
one (picky) comment below.


- changedFiles.R:
changedFiles <- function(snapshot, timestamp = tempfile("timestamp"),
file.info = NULL,
  md5sum = FALSE, full.names = FALSE, ...) {
 dosnapshot <- function(args) {
 fullnames <- do.call(list.files, c(full.names = TRUE, args))
 names <- do.call(list.files, c(full.names = full.names, args))
 if (isTRUE(file.info) || (is.character(file.info) &&
length(file.info))) {
 info <- file.info(fullnames)
 rownames(info) <- names
 if (isTRUE(file.info))
 file.info <- c("size", "isdir", "mode", "mtime")
 } else
 info <- data.frame(row.names=names)
 if (md5sum)
 info <- data.frame(info, md5sum = tools::md5sum(fullnames))
 list(info = info, timestamp = timestamp, file.info = file.info,
  md5sum = md5sum, full.names = full.names, args = args)
 }
 if (missing(snapshot) || !inherits(snapshot, "changedFilesSnapshot")) {
 if (length(timestamp) == 1)
 file.create(timestamp)
 if (missing(snapshot)) snapshot <- "."
 pre <- dosnapshot(list(path = snapshot, ...))
 pre$pre <- pre$info
 pre$info <- NULL
 pre$wd <- getwd()
 class(pre) <- "changedFilesSnapshot"
 return(pre)
 }

 if (missing(timestamp)) timestamp <- snapshot$timestamp
 if (missing(file.info) || isTRUE(file.info)) file.info <-
snapshot$file.info
 if (identical(file.info, FALSE)) file.info <- NULL
 if (missing(md5sum))md5sum <- snapshot$md5sum
 if (missing(full.names)) full.names <- snapshot$full.names

 pre <- snapshot$pre
 savewd <- getwd()
 on.exit(setwd(savewd))
 setwd(snapshot$wd)

 args <- snapshot$args
 newargs <- list(...)
 args[names(newargs)] <- newargs
 post <- dosnapshot(args)$info
 prenames <- rownames(pre)
 postnames <- rownames(post)

 added <- setdiff(postnames, prenames)
 deleted <- setdiff(prenames, postnames)
 common <- intersect(prenames, postnames)

 if (length(file.info)) {
 preinfo <- pre[common, file.info]
 postinfo <- post[common, file.info]
 changes <- preinfo != postinfo
 }
 else changes <- matrix(logical(0), nrow = length(common), ncol = 0,
dimnames = list(common, character(0)))
 if (length(timestamp))
 changes <- cbind(changes, Newer = file_test("-nt", common,
timestamp))
 if (md5sum) {
 premd5 <- pre[common, "md5sum"]
 postmd5 <- post[common, "md5sum"]
 changes <- cbind(changes, md5sum = premd5 != postmd5)
 }
 changes1 <- changes[rowSums(changes, na.rm = TRUE) > 0, , drop = FALSE]
 changed <- rownames(changes1)
 structure(list(added = added, deleted = deleted, changed = changed,
 unchanged = setdiff(common, changed), changes = changes), class =
"changedFiles")
}

print.changedFilesSnapshot <- function(x, ...) {
 cat("changedFiles snapshot:\n timestamp = \"", x$timestamp, "\"\n
file.info = ",
 if (length(x$file.info)) paste(paste0('"', x$file.info, '"'),
collapse=","),
 "\n md5sum = ", x$md5sum, "\n args = ", deparse(x$args, control =
NULL), "\n", sep="")
 x
}

print.changedFiles <- function(x, ...) {
 if (length(x$added)) cat("Files added:\n",  paste0("  ", x$added,
collapse="\n"), "\n", sep="")
 if (length(x$deleted)) cat("Files deleted:\n",  paste0("  ", x$deleted,
collapse="\n"), "\n", sep="")
 changes <- x$changes
 changes <- changes[rowSums(changes, na.rm = TRUE) > 0, , drop=FALSE]
 changes <- changes[, colSums(changes, na.rm = TRUE) > 0, drop=FALSE]
 if (nrow(changes)) {
 cat("Files changed:\n")
 print(changes)
 }
 x
}
--

--- changedFiles.Rd:
\name{changedFiles}
\alias{changedFiles}
\alias{print.changedFiles}
\alias{print.changedFilesSnapshot}
\title{
Detect which files have changed
}
\description{
On the first call, \code{changedFiles} takes a snapshot of a selection of
files.  In subsequent
calls, it takes another snapshot, and returns an object containing data on
the
differences between the two snapshots.  The snapshots need not be the same
directory;
this could be used to compare two directories.
}
\usage{
changedFiles(snapshot, timestamp = tempfile("timestamp"), file.info = NULL,
  md5sum = FALSE, full.names = FALSE, ...)
}
\arguments{
   \item{snapshot}{
Th

Re: [Rd] ASCII art in function documentation?

2013-09-05 Thread Brian G. Peterson

On 09/05/2013 09:10 AM, Rainer M Krug wrote:

  want to include ascii art in a function documentation which should
look as follow:

,
| +--+--+--+
| | 1/16 | 1/16 | 1/16 |
| +--+--+--+
| | 1/16 | 8/16 | 1/16 |
| +--+--+--+
| | 1/16 | 1/16 | 1/16 |
| +--+--+--+
`


to keep the monospaced font even in html, I decided to use \code{}:


Wouldn't it be best to use the relatively new \figure markup with 
alternate text?


http://cran.r-project.org/doc/manuals/R-exts.html#Figures

Regards,

Brian


--
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] ASCII art in function documentation - difference html and text output?

2013-09-05 Thread Rainer M Krug
Found a solution.

putting \cr at the end of each line inserts a carriage return, but no
additional empty line. So

,
| \code{+--+--+--+} \cr
| \code{| 1/16 | 1/16 | 1/16 |} \cr
| \code{+--+--+--+} \cr
| \code{| 1/16 | 8/16 | 1/16 |} \cr
| \code{+--+--+--+} \cr
| \code{| 1/16 | 1/16 | 1/16 |} \cr
| \code{+--+--+--+} \cr
`

produces the desired output.


But interestingly,

,
| \code{
| +--+--+--+ \cr
| | 1/16 | 1/16 | 1/16 | \cr
| +--+--+--+ \cr
| | 1/16 | 8/16 | 1/16 | \cr
| +--+--+--+ \cr
| | 1/16 | 1/16 | 1/16 | \cr
| +--+--+--+ \cr
| }
`

produces the correct output in html, 

,
| 
|  +--+--+--+  | 1/16 | 1/16 | 1/16 |
|+--+--+--+  | 1/16 | 8/16 | 1/16 | 
|   +--+--+--+  | 1/16 | 1/16 | 1/16 | 
|   +--+--+--+  
| 
`

but

,
|  ' +--+--+--+
|  | 1/16 | 1/16 | 1/16 |
| 
|  +--+--+--+
|  | 1/16 | 8/16 | 1/16 |
|  +--+--+--+
|  | 1/16 | 1/16 | 1/16 |
|  +--+--+--+
`

in the text version - is there a bug somewhere?

Thanks,

Rainer



Rainer M Krug  writes:

> Sarah Goslee  writes:
>
>> Untested, but did you try wrapping the whole thing in a single code block:
>
> Nope - also in one line.
>
> Rainer
>
>>
>> \code{
>> all
>> the
>> things
>> }
>>
>> Sarah
>>
>> On Thu, Sep 5, 2013 at 10:10 AM, Rainer M Krug  wrote:
>>> Hi
>>>
>>> I want to include ascii art in a function documentation which should
>>> look as follow:
>>>
>>> ,
>>> | +--+--+--+
>>> | | 1/16 | 1/16 | 1/16 |
>>> | +--+--+--+
>>> | | 1/16 | 8/16 | 1/16 |
>>> | +--+--+--+
>>> | | 1/16 | 1/16 | 1/16 |
>>> | +--+--+--+
>>> `
>>>
>>>
>>> to keep the monospaced font even in html, I decided to use \code{}:
>>>
>>> ,
>>> | \code{+--+--+--+}
>>> |
>>> | \code{| 1/16 | 1/16 | 1/16 |}
>>> |
>>> | \code{+--+--+--+}
>>> |
>>> | \code{| 1/16 | 8/16 | 1/16 |}
>>> |
>>> | \code{+--+--+--+}
>>> |
>>> | \code{| 1/16 | 1/16 | 1/16 |}
>>> |
>>> | \code{+--+--+--+}
>>> `
>>>
>>> But the result was an empty line between each text:
>>>
>>> ,
>>> |  '+--+--+--+'
>>> |
>>> |  '| 1/16 | 1/16 | 1/16 |'
>>> |
>>> |  '+--+--+--+'
>>> |
>>> |  '| 1/16 | 8/16 | 1/16 |'
>>> |
>>> |  '+--+--+--+'
>>> |
>>> |  '| 1/16 | 1/16 | 1/16 |'
>>> |
>>> |  '+--+--+--+'
>>> `
>>>
>>> and when no empty lines were included obviously put everything behind
>>> each other.
>>>
>>> My question:
>>>
>>> Is there a way that I can achieve the ASCII art as shown above? Is there
>>> a way of having a \linebreak which does not insert a new line?
>>>
>>> Thanks,
>>>
>>> Rainer
>>>
>>>
>>> --
> <#secure method=pgpmime mode=sign>
>
<#secure method=pgpmime mode=sign>

-- 
Rainer M. Krug

email: RMKruggmailcom

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] ASCII art in function documentation?

2013-09-05 Thread Sarah Goslee
Now that I'm at the computer with my R code, I've used both
\preformatted{}
and \cr to force line breaks.

Some combination of those may work for you.

Sarah


On Thu, Sep 5, 2013 at 11:10 AM, Rainer M Krug  wrote:
> Sarah Goslee  writes:
>
>> Untested, but did you try wrapping the whole thing in a single code block:
>
> Nope - also in one line.
>
> Rainer
>
>>
>> \code{
>> all
>> the
>> things
>> }
>>
>> Sarah
>>
>> On Thu, Sep 5, 2013 at 10:10 AM, Rainer M Krug  wrote:
>>> Hi
>>>
>>> I want to include ascii art in a function documentation which should
>>> look as follow:
>>>
>>> ,
>>> | +--+--+--+
>>> | | 1/16 | 1/16 | 1/16 |
>>> | +--+--+--+
>>> | | 1/16 | 8/16 | 1/16 |
>>> | +--+--+--+
>>> | | 1/16 | 1/16 | 1/16 |
>>> | +--+--+--+
>>> `
>>>
>>>
>>> to keep the monospaced font even in html, I decided to use \code{}:
>>>
>>> ,
>>> | \code{+--+--+--+}
>>> |
>>> | \code{| 1/16 | 1/16 | 1/16 |}
>>> |
>>> | \code{+--+--+--+}
>>> |
>>> | \code{| 1/16 | 8/16 | 1/16 |}
>>> |
>>> | \code{+--+--+--+}
>>> |
>>> | \code{| 1/16 | 1/16 | 1/16 |}
>>> |
>>> | \code{+--+--+--+}
>>> `
>>>
>>> But the result was an empty line between each text:
>>>
>>> ,
>>> |  '+--+--+--+'
>>> |
>>> |  '| 1/16 | 1/16 | 1/16 |'
>>> |
>>> |  '+--+--+--+'
>>> |
>>> |  '| 1/16 | 8/16 | 1/16 |'
>>> |
>>> |  '+--+--+--+'
>>> |
>>> |  '| 1/16 | 1/16 | 1/16 |'
>>> |
>>> |  '+--+--+--+'
>>> `
>>>
>>> and when no empty lines were included obviously put everything behind
>>> each other.
>>>
>>> My question:
>>>
>>> Is there a way that I can achieve the ASCII art as shown above? Is there
>>> a way of having a \linebreak which does not insert a new line?
>>>
>>> Thanks,
>>>
>>> Rainer
>>>
>>>
>>> --
> <#secure method=pgpmime mode=sign>
>
> --
> Rainer M. Krug
>
> email: RMKruggmailcom
>


-- 
Sarah Goslee
http://www.functionaldiversity.org

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Comments requested on "changedFiles" function

2013-09-05 Thread Duncan Murdoch

On 05/09/2013 12:32 PM, Dr Gregory Jefferis wrote:

Dear Duncan,

This certainly looks useful. Might you consider adding the ability to
supply an alternative digest function? Details below.


Thanks, that's a good idea.

Duncan Murdoch


I often use a homemade "make" type function which starts by looking at
modification times e.g. in a private package

https://github.com/jefferis/nat.utils/blob/master/R/make.r

For some of my work, I use hash functions. However because I typically
work with many large files I often use a special digest process e.g.
using the crc checksum embedded in a gzip file directly or hashing only
the part of a large file that is (almost) certain to change.

Perhaps (code unchecked) along the lines of:

changedFiles <- function(snapshot, timestamp = tempfile("timestamp"),
file.info = NULL,
digest = FALSE, digestfun=NULL, full.names = FALSE, ...)

if(digest){
if(is.null(digestfun)) digestfun=tools::md5sum
else digestfun=match.fun(digestfun)
info <- data.frame(info, digest = digestfun(fullnames))
}

etc

OR alternatively using only one argument:

changedFiles <- function(snapshot, timestamp = tempfile("timestamp"),
file.info = NULL,
digest = FALSE, full.names = FALSE, ...)

if(is.logical(digest)){
if(digest) digestfun=tools::md5sum
} else {
# Assume that digest specifies a function that we want to use
digestfun=match.fun(digest)
digest=TRUE
}

if(digest)
info <- data.frame(info, digest = digestfun(fullnames))

etc

Many thanks,

Greg.

On 4 Sep 2013, at 18:53, Duncan Murdoch wrote:

> In a number of places internal to R, we need to know which files have
> changed (e.g. after building a vignette).  I've just written a general
> purpose function "changedFiles" that I'll probably commit to R-devel.
> Comments on the design (or bug reports) would be appreciated.
>
> The source for the function and the Rd page for it are inline below.
>
> - changedFiles.R:
> changedFiles <- function(snapshot, timestamp = tempfile("timestamp"),
> file.info = NULL,
>   md5sum = FALSE, full.names = FALSE, ...) {
> dosnapshot <- function(args) {
> fullnames <- do.call(list.files, c(full.names = TRUE, args))
> names <- do.call(list.files, c(full.names = full.names, args))
> if (isTRUE(file.info) || (is.character(file.info) &&
> length(file.info))) {
>  info <- file.info(fullnames)
> rownames(info) <- names
>  if (isTRUE(file.info))
>  file.info <- c("size", "isdir", "mode", "mtime")
> } else
>  info <- data.frame(row.names=names)
> if (md5sum)
> info <- data.frame(info, md5sum = tools::md5sum(fullnames))
> list(info = info, timestamp = timestamp, file.info = file.info,
> md5sum = md5sum, full.names = full.names, args = args)


--
Gregory Jefferis, PhD   Tel: 01223 267048
Division of Neurobiology
MRC Laboratory of Molecular Biology
Francis Crick Avenue
Cambridge Biomedical Campus
Cambridge, CB2 OQH, UK

http://www2.mrc-lmb.cam.ac.uk/group-leaders/h-to-m/g-jefferis
http://jefferislab.org
http://flybrain.stanford.edu


__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] ASCII art in function documentation?

2013-09-05 Thread Rainer M Krug
Hi

I want to include ascii art in a function documentation which should
look as follow:

,
| +--+--+--+
| | 1/16 | 1/16 | 1/16 |
| +--+--+--+
| | 1/16 | 8/16 | 1/16 |
| +--+--+--+
| | 1/16 | 1/16 | 1/16 |
| +--+--+--+
`


to keep the monospaced font even in html, I decided to use \code{}:

,
| \code{+--+--+--+}
| 
| \code{| 1/16 | 1/16 | 1/16 |}
| 
| \code{+--+--+--+}
| 
| \code{| 1/16 | 8/16 | 1/16 |}
| 
| \code{+--+--+--+}
| 
| \code{| 1/16 | 1/16 | 1/16 |}
| 
| \code{+--+--+--+}
`

But the result was an empty line between each text:

,
|  '+--+--+--+'
| 
|  '| 1/16 | 1/16 | 1/16 |'
| 
|  '+--+--+--+'
| 
|  '| 1/16 | 8/16 | 1/16 |'
| 
|  '+--+--+--+'
| 
|  '| 1/16 | 1/16 | 1/16 |'
| 
|  '+--+--+--+'
`

and when no empty lines were included obviously put everything behind
each other.

My question:

Is there a way that I can achieve the ASCII art as shown above? Is there
a way of having a \linebreak which does not insert a new line?

Thanks,

Rainer


-- 
Rainer M. Krug

email: RMKruggmailcom

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] ASCII art in function documentation?

2013-09-05 Thread Sarah Goslee
Untested, but did you try wrapping the whole thing in a single code block:

\code{
all
the
things
}

Sarah

On Thu, Sep 5, 2013 at 10:10 AM, Rainer M Krug  wrote:
> Hi
>
> I want to include ascii art in a function documentation which should
> look as follow:
>
> ,
> | +--+--+--+
> | | 1/16 | 1/16 | 1/16 |
> | +--+--+--+
> | | 1/16 | 8/16 | 1/16 |
> | +--+--+--+
> | | 1/16 | 1/16 | 1/16 |
> | +--+--+--+
> `
>
>
> to keep the monospaced font even in html, I decided to use \code{}:
>
> ,
> | \code{+--+--+--+}
> |
> | \code{| 1/16 | 1/16 | 1/16 |}
> |
> | \code{+--+--+--+}
> |
> | \code{| 1/16 | 8/16 | 1/16 |}
> |
> | \code{+--+--+--+}
> |
> | \code{| 1/16 | 1/16 | 1/16 |}
> |
> | \code{+--+--+--+}
> `
>
> But the result was an empty line between each text:
>
> ,
> |  '+--+--+--+'
> |
> |  '| 1/16 | 1/16 | 1/16 |'
> |
> |  '+--+--+--+'
> |
> |  '| 1/16 | 8/16 | 1/16 |'
> |
> |  '+--+--+--+'
> |
> |  '| 1/16 | 1/16 | 1/16 |'
> |
> |  '+--+--+--+'
> `
>
> and when no empty lines were included obviously put everything behind
> each other.
>
> My question:
>
> Is there a way that I can achieve the ASCII art as shown above? Is there
> a way of having a \linebreak which does not insert a new line?
>
> Thanks,
>
> Rainer
>
>
> --


-- 
Sarah Goslee
http://www.functionaldiversity.org

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] ASCII art in function documentation?

2013-09-05 Thread Rainer M Krug
OK - it boils down to an roxygen problem.

I will send a separate email for it.
Thanks,

Rainer


Sarah Goslee  writes:

> Now that I'm at the computer with my R code, I've used both
> \preformatted{}
> and \cr to force line breaks.
>
> Some combination of those may work for you.
>
> Sarah
>
>
> On Thu, Sep 5, 2013 at 11:10 AM, Rainer M Krug  wrote:
>> Sarah Goslee  writes:
>>
>>> Untested, but did you try wrapping the whole thing in a single code block:
>>
>> Nope - also in one line.
>>
>> Rainer
>>
>>>
>>> \code{
>>> all
>>> the
>>> things
>>> }
>>>
>>> Sarah
>>>
>>> On Thu, Sep 5, 2013 at 10:10 AM, Rainer M Krug  wrote:
 Hi

 I want to include ascii art in a function documentation which should
 look as follow:

 ,
 | +--+--+--+
 | | 1/16 | 1/16 | 1/16 |
 | +--+--+--+
 | | 1/16 | 8/16 | 1/16 |
 | +--+--+--+
 | | 1/16 | 1/16 | 1/16 |
 | +--+--+--+
 `


 to keep the monospaced font even in html, I decided to use \code{}:

 ,
 | \code{+--+--+--+}
 |
 | \code{| 1/16 | 1/16 | 1/16 |}
 |
 | \code{+--+--+--+}
 |
 | \code{| 1/16 | 8/16 | 1/16 |}
 |
 | \code{+--+--+--+}
 |
 | \code{| 1/16 | 1/16 | 1/16 |}
 |
 | \code{+--+--+--+}
 `

 But the result was an empty line between each text:

 ,
 |  '+--+--+--+'
 |
 |  '| 1/16 | 1/16 | 1/16 |'
 |
 |  '+--+--+--+'
 |
 |  '| 1/16 | 8/16 | 1/16 |'
 |
 |  '+--+--+--+'
 |
 |  '| 1/16 | 1/16 | 1/16 |'
 |
 |  '+--+--+--+'
 `

 and when no empty lines were included obviously put everything behind
 each other.

 My question:

 Is there a way that I can achieve the ASCII art as shown above? Is there
 a way of having a \linebreak which does not insert a new line?

 Thanks,

 Rainer


 --
>> <#secure method=pgpmime mode=sign>
>>
>> --
>> Rainer M. Krug
>>
>> email: RMKruggmailcom
>>
>
<#secure method=pgpmime mode=sign>

-- 
Rainer M. Krug

email: RMKruggmailcom

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Comments requested on "changedFiles" function

2013-09-05 Thread Dr Gregory Jefferis

Dear Duncan,

This certainly looks useful. Might you consider adding the ability to 
supply an alternative digest function? Details below.


I often use a homemade "make" type function which starts by looking at 
modification times e.g. in a private package


https://github.com/jefferis/nat.utils/blob/master/R/make.r

For some of my work, I use hash functions. However because I typically 
work with many large files I often use a special digest process e.g. 
using the crc checksum embedded in a gzip file directly or hashing only 
the part of a large file that is (almost) certain to change.


Perhaps (code unchecked) along the lines of:

changedFiles <- function(snapshot, timestamp = tempfile("timestamp"), 
file.info = NULL,

digest = FALSE, digestfun=NULL, full.names = FALSE, ...)

if(digest){
if(is.null(digestfun)) digestfun=tools::md5sum
else digestfun=match.fun(digestfun)
info <- data.frame(info, digest = digestfun(fullnames))
}

etc

OR alternatively using only one argument:

changedFiles <- function(snapshot, timestamp = tempfile("timestamp"), 
file.info = NULL,

digest = FALSE, full.names = FALSE, ...)

if(is.logical(digest)){
if(digest) digestfun=tools::md5sum
} else {
# Assume that digest specifies a function that we want to use
digestfun=match.fun(digest)
digest=TRUE
}

if(digest)
info <- data.frame(info, digest = digestfun(fullnames))

etc

Many thanks,

Greg.

On 4 Sep 2013, at 18:53, Duncan Murdoch wrote:

In a number of places internal to R, we need to know which files have 
changed (e.g. after building a vignette).  I've just written a general 
purpose function "changedFiles" that I'll probably commit to R-devel.  
Comments on the design (or bug reports) would be appreciated.


The source for the function and the Rd page for it are inline below.

- changedFiles.R:
changedFiles <- function(snapshot, timestamp = tempfile("timestamp"), 
file.info = NULL,

  md5sum = FALSE, full.names = FALSE, ...) {
dosnapshot <- function(args) {
fullnames <- do.call(list.files, c(full.names = TRUE, args))
names <- do.call(list.files, c(full.names = full.names, args))
if (isTRUE(file.info) || (is.character(file.info) && 
length(file.info))) {

 info <- file.info(fullnames)
rownames(info) <- names
 if (isTRUE(file.info))
 file.info <- c("size", "isdir", "mode", "mtime")
} else
 info <- data.frame(row.names=names)
if (md5sum)
info <- data.frame(info, md5sum = tools::md5sum(fullnames))
list(info = info, timestamp = timestamp, file.info = file.info,
md5sum = md5sum, full.names = full.names, args = args)



--
Gregory Jefferis, PhD   Tel: 01223 267048
Division of Neurobiology
MRC Laboratory of Molecular Biology
Francis Crick Avenue
Cambridge Biomedical Campus
Cambridge, CB2 OQH, UK

http://www2.mrc-lmb.cam.ac.uk/group-leaders/h-to-m/g-jefferis
http://jefferislab.org
http://flybrain.stanford.edu

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] ASCII art in function documentation?

2013-09-05 Thread Rainer M Krug
Sarah Goslee  writes:

> Untested, but did you try wrapping the whole thing in a single code block:

Nope - also in one line.

Rainer

>
> \code{
> all
> the
> things
> }
>
> Sarah
>
> On Thu, Sep 5, 2013 at 10:10 AM, Rainer M Krug  wrote:
>> Hi
>>
>> I want to include ascii art in a function documentation which should
>> look as follow:
>>
>> ,
>> | +--+--+--+
>> | | 1/16 | 1/16 | 1/16 |
>> | +--+--+--+
>> | | 1/16 | 8/16 | 1/16 |
>> | +--+--+--+
>> | | 1/16 | 1/16 | 1/16 |
>> | +--+--+--+
>> `
>>
>>
>> to keep the monospaced font even in html, I decided to use \code{}:
>>
>> ,
>> | \code{+--+--+--+}
>> |
>> | \code{| 1/16 | 1/16 | 1/16 |}
>> |
>> | \code{+--+--+--+}
>> |
>> | \code{| 1/16 | 8/16 | 1/16 |}
>> |
>> | \code{+--+--+--+}
>> |
>> | \code{| 1/16 | 1/16 | 1/16 |}
>> |
>> | \code{+--+--+--+}
>> `
>>
>> But the result was an empty line between each text:
>>
>> ,
>> |  '+--+--+--+'
>> |
>> |  '| 1/16 | 1/16 | 1/16 |'
>> |
>> |  '+--+--+--+'
>> |
>> |  '| 1/16 | 8/16 | 1/16 |'
>> |
>> |  '+--+--+--+'
>> |
>> |  '| 1/16 | 1/16 | 1/16 |'
>> |
>> |  '+--+--+--+'
>> `
>>
>> and when no empty lines were included obviously put everything behind
>> each other.
>>
>> My question:
>>
>> Is there a way that I can achieve the ASCII art as shown above? Is there
>> a way of having a \linebreak which does not insert a new line?
>>
>> Thanks,
>>
>> Rainer
>>
>>
>> --
<#secure method=pgpmime mode=sign>

-- 
Rainer M. Krug

email: RMKruggmailcom

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] libR.so: cannot open shared object file

2013-09-05 Thread gianluca.mastranto...@yahoo.it

just for completion

i need to use
library(Model, lib.loc="user/area/myRLib")
because if i use
library(Model)
i get this message
Error in library("BayesWrap") : there is no package called 'BayesWrap'




Il 05/09/13 11:59, gianluca.mastranto...@yahoo.it ha scritto:

First of all, thanks for your help.

I did all the things you told me. I was able to load the library, but 
then


Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared object 
'/lustre/work/gjona2/Wrap/BayesWrap/libs/BayesWrap.so':

  libR.so: cannot open shared object file: No such file or directory
In addition: Warning message:
package 'BayesWrap' was built under R version 2.15.2
Error: package/namespace load failed for 'BayesWrap'
Execution halted

what does it means?

G.M.

Il 04/09/13 22:42, Prof Brian Ripley ha scritto:

On 04/09/2013 19:58, Geoff Jentry wrote:

Can you add some details?
Suppose i have the package Model.tar.gz and my writable are is in
user/area, what i have to do next to install the package?


What I was picturing was something like this (forgive me if syntax 
isn't

100%):

mkdir user/area/myRLib
R CMD INSTALL --library=user/area/myRLib Model.tar.gz

and then in R:
library(Model, lib.loc="user/area/myRLib")

Note though Brian Ripley's response to me where he indicates that this
is handled automatically.


Yes,  install.packages("Model.tar.gz") should suffice.



-J

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel







__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Comments requested on "changedFiles" function

2013-09-05 Thread Scott Kostyshak
On Thu, Sep 5, 2013 at 6:48 AM, Duncan Murdoch  wrote:
> On 13-09-04 11:36 PM, Scott Kostyshak wrote:
>>
>> On Wed, Sep 4, 2013 at 1:53 PM, Duncan Murdoch 
>> wrote:
>>>
>>> In a number of places internal to R, we need to know which files have
>>> changed (e.g. after building a vignette).  I've just written a general
>>> purpose function "changedFiles" that I'll probably commit to R-devel.
>>> Comments on the design (or bug reports) would be appreciated.
>>>
>>> The source for the function and the Rd page for it are inline below.
>>
>>
>> This looks like a useful function. Thanks for writing it. I have only
>> one (picky) comment below.
>>
>>> - changedFiles.R:
>>> changedFiles <- function(snapshot, timestamp = tempfile("timestamp"),
>>> file.info = NULL,
>>>   md5sum = FALSE, full.names = FALSE, ...) {
>>>  dosnapshot <- function(args) {
>>>  fullnames <- do.call(list.files, c(full.names = TRUE, args))
>>>  names <- do.call(list.files, c(full.names = full.names, args))
>>>  if (isTRUE(file.info) || (is.character(file.info) &&
>>> length(file.info))) {
>>>  info <- file.info(fullnames)
>>>  rownames(info) <- names
>>>  if (isTRUE(file.info))
>>>  file.info <- c("size", "isdir", "mode", "mtime")
>>>  } else
>>>  info <- data.frame(row.names=names)
>>>  if (md5sum)
>>>  info <- data.frame(info, md5sum = tools::md5sum(fullnames))
>>>  list(info = info, timestamp = timestamp, file.info = file.info,
>>>   md5sum = md5sum, full.names = full.names, args = args)
>>>  }
>>>  if (missing(snapshot) || !inherits(snapshot,
>>> "changedFilesSnapshot")) {
>>>  if (length(timestamp) == 1)
>>>  file.create(timestamp)
>>>  if (missing(snapshot)) snapshot <- "."
>>>  pre <- dosnapshot(list(path = snapshot, ...))
>>>  pre$pre <- pre$info
>>>  pre$info <- NULL
>>>  pre$wd <- getwd()
>>>  class(pre) <- "changedFilesSnapshot"
>>>  return(pre)
>>>  }
>>>
>>>  if (missing(timestamp)) timestamp <- snapshot$timestamp
>>>  if (missing(file.info) || isTRUE(file.info)) file.info <-
>>> snapshot$file.info
>>>  if (identical(file.info, FALSE)) file.info <- NULL
>>>  if (missing(md5sum))md5sum <- snapshot$md5sum
>>>  if (missing(full.names)) full.names <- snapshot$full.names
>>>
>>>  pre <- snapshot$pre
>>>  savewd <- getwd()
>>>  on.exit(setwd(savewd))
>>>  setwd(snapshot$wd)
>>>
>>>  args <- snapshot$args
>>>  newargs <- list(...)
>>>  args[names(newargs)] <- newargs
>>>  post <- dosnapshot(args)$info
>>>  prenames <- rownames(pre)
>>>  postnames <- rownames(post)
>>>
>>>  added <- setdiff(postnames, prenames)
>>>  deleted <- setdiff(prenames, postnames)
>>>  common <- intersect(prenames, postnames)
>>>
>>>  if (length(file.info)) {
>>>  preinfo <- pre[common, file.info]
>>>  postinfo <- post[common, file.info]
>>>  changes <- preinfo != postinfo
>>>  }
>>>  else changes <- matrix(logical(0), nrow = length(common), ncol = 0,
>>> dimnames = list(common, character(0)))
>>>  if (length(timestamp))
>>>  changes <- cbind(changes, Newer = file_test("-nt", common,
>>> timestamp))
>>>  if (md5sum) {
>>>  premd5 <- pre[common, "md5sum"]
>>>  postmd5 <- post[common, "md5sum"]
>>>  changes <- cbind(changes, md5sum = premd5 != postmd5)
>>>  }
>>>  changes1 <- changes[rowSums(changes, na.rm = TRUE) > 0, , drop =
>>> FALSE]
>>>  changed <- rownames(changes1)
>>>  structure(list(added = added, deleted = deleted, changed = changed,
>>>  unchanged = setdiff(common, changed), changes = changes), class
>>> =
>>> "changedFiles")
>>> }
>>>
>>> print.changedFilesSnapshot <- function(x, ...) {
>>>  cat("changedFiles snapshot:\n timestamp = \"", x$timestamp, "\"\n
>>> file.info = ",
>>>  if (length(x$file.info)) paste(paste0('"', x$file.info, '"'),
>>> collapse=","),
>>>  "\n md5sum = ", x$md5sum, "\n args = ", deparse(x$args, control
>>> =
>>> NULL), "\n", sep="")
>>>  x
>>> }
>>>
>>> print.changedFiles <- function(x, ...) {
>>>  if (length(x$added)) cat("Files added:\n",  paste0("  ", x$added,
>>> collapse="\n"), "\n", sep="")
>>>  if (length(x$deleted)) cat("Files deleted:\n",  paste0("  ",
>>> x$deleted,
>>> collapse="\n"), "\n", sep="")
>>>  changes <- x$changes
>>>  changes <- changes[rowSums(changes, na.rm = TRUE) > 0, , drop=FALSE]
>>>  changes <- changes[, colSums(changes, na.rm = TRUE) > 0, drop=FALSE]
>>>  if (nrow(changes)) {
>>>  cat("Files changed:\n")
>>>  print(changes)
>>>  }
>>>  x
>>> }
>>> --
>>>
>>> --- changedFiles.Rd:
>>> \name{changedFiles}
>>> \alias{changedFiles}
>>> \alias{print.changedFiles}
>>> \alias{print.changedFilesSnapsh

Re: [Rd] libR.so: cannot open shared object file

2013-09-05 Thread Prof Brian Ripley

On 05/09/2013 21:28, gianluca.mastranto...@yahoo.it wrote:

just for completion

i need to use
library(Model, lib.loc="user/area/myRLib")
because if i use
library(Model)
i get this message
Error in library("BayesWrap") : there is no package called 'BayesWrap'


For the record: not if you follow my suggestion.

See ?.libPaths for why.





Il 05/09/13 11:59, gianluca.mastranto...@yahoo.it ha scritto:

First of all, thanks for your help.

I did all the things you told me. I was able to load the library, but
then

Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared object
'/lustre/work/gjona2/Wrap/BayesWrap/libs/BayesWrap.so':
  libR.so: cannot open shared object file: No such file or directory
In addition: Warning message:
package 'BayesWrap' was built under R version 2.15.2
Error: package/namespace load failed for 'BayesWrap'
Execution halted

what does it means?

G.M.

Il 04/09/13 22:42, Prof Brian Ripley ha scritto:

On 04/09/2013 19:58, Geoff Jentry wrote:

Can you add some details?
Suppose i have the package Model.tar.gz and my writable are is in
user/area, what i have to do next to install the package?


What I was picturing was something like this (forgive me if syntax
isn't
100%):

mkdir user/area/myRLib
R CMD INSTALL --library=user/area/myRLib Model.tar.gz

and then in R:
library(Model, lib.loc="user/area/myRLib")

Note though Brian Ripley's response to me where he indicates that this
is handled automatically.


Yes,  install.packages("Model.tar.gz") should suffice.



-J

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel










--
Brian D. Ripley,  rip...@stats.ox.ac.uk
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, UKFax:  +44 1865 272595

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Comments requested on "changedFiles" function

2013-09-05 Thread Hadley Wickham
> This approach does have the difficulty that users could attempt to compare
> snapshots that were taken with different options and that can't be
> compared, but that should be an easy error to detect.

FYI I implemented that approach in testthat:
https://github.com/hadley/testthat/blob/master/R/watcher.r - it's a
bit more general, because it just sits in the background and listens
for changes, dispatching to a callback.

Hadley

-- 
Chief Scientist, RStudio
http://had.co.nz/

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] ASCII art in function documentation - difference html and text output?

2013-09-05 Thread Marc Schwartz
Rainer,

Have you tried:

\preformatted{...}

which is documented in R-exts to preserve line breaks:

Indicate text that is a literal example of a piece of a program. Text is 
displayed using typewriter font if possible. Formatting, e.g. line breaks, is 
preserved. (Note that this includes a line break after the initial {, so 
typically text should start on the same line as the command.)
Due to limitations in LaTeX as of this writing, this macro may not be nested 
within other markup macros other than \dQuote and \sQuote, as errors or bad 
formatting may result. 


I have not used it myself, but might be worth a try, plus or minus the \cr use.

Regards,

Marc Schwartz

On Sep 5, 2013, at 10:23 AM, Rainer M Krug  wrote:

> Found a solution.
> 
> putting \cr at the end of each line inserts a carriage return, but no
> additional empty line. So
> 
> ,
> | \code{+--+--+--+} \cr
> | \code{| 1/16 | 1/16 | 1/16 |} \cr
> | \code{+--+--+--+} \cr
> | \code{| 1/16 | 8/16 | 1/16 |} \cr
> | \code{+--+--+--+} \cr
> | \code{| 1/16 | 1/16 | 1/16 |} \cr
> | \code{+--+--+--+} \cr
> `
> 
> produces the desired output.
> 
> 
> But interestingly,
> 
> ,
> | \code{
> | +--+--+--+ \cr
> | | 1/16 | 1/16 | 1/16 | \cr
> | +--+--+--+ \cr
> | | 1/16 | 8/16 | 1/16 | \cr
> | +--+--+--+ \cr
> | | 1/16 | 1/16 | 1/16 | \cr
> | +--+--+--+ \cr
> | }
> `
> 
> produces the correct output in html, 
> 
> ,
> | 
> |  +--+--+--+  | 1/16 | 1/16 | 1/16 |
> |+--+--+--+  | 1/16 | 8/16 | 1/16 | 
> |   +--+--+--+  | 1/16 | 1/16 | 1/16 | 
> |   +--+--+--+  
> | 
> `
> 
> but
> 
> ,
> |  ' +--+--+--+
> |  | 1/16 | 1/16 | 1/16 |
> | 
> |  +--+--+--+
> |  | 1/16 | 8/16 | 1/16 |
> |  +--+--+--+
> |  | 1/16 | 1/16 | 1/16 |
> |  +--+--+--+
> `
> 
> in the text version - is there a bug somewhere?
> 
> Thanks,
> 
> Rainer
> 
> 
> 
> Rainer M Krug  writes:
> 
>> Sarah Goslee  writes:
>> 
>>> Untested, but did you try wrapping the whole thing in a single code block:
>> 
>> Nope - also in one line.
>> 
>> Rainer
>> 
>>> 
>>> \code{
>>> all
>>> the
>>> things
>>> }
>>> 
>>> Sarah
>>> 
>>> On Thu, Sep 5, 2013 at 10:10 AM, Rainer M Krug  wrote:
 Hi
 
 I want to include ascii art in a function documentation which should
 look as follow:
 
 ,
 | +--+--+--+
 | | 1/16 | 1/16 | 1/16 |
 | +--+--+--+
 | | 1/16 | 8/16 | 1/16 |
 | +--+--+--+
 | | 1/16 | 1/16 | 1/16 |
 | +--+--+--+
 `
 
 
 to keep the monospaced font even in html, I decided to use \code{}:
 
 ,
 | \code{+--+--+--+}
 |
 | \code{| 1/16 | 1/16 | 1/16 |}
 |
 | \code{+--+--+--+}
 |
 | \code{| 1/16 | 8/16 | 1/16 |}
 |
 | \code{+--+--+--+}
 |
 | \code{| 1/16 | 1/16 | 1/16 |}
 |
 | \code{+--+--+--+}
 `
 
 But the result was an empty line between each text:
 
 ,
 |  '+--+--+--+'
 |
 |  '| 1/16 | 1/16 | 1/16 |'
 |
 |  '+--+--+--+'
 |
 |  '| 1/16 | 8/16 | 1/16 |'
 |
 |  '+--+--+--+'
 |
 |  '| 1/16 | 1/16 | 1/16 |'
 |
 |  '+--+--+--+'
 `
 
 and when no empty lines were included obviously put everything behind
 each other.
 
 My question:
 
 Is there a way that I can achieve the ASCII art as shown above? Is there
 a way of having a \linebreak which does not insert a new line?
 
 Thanks,
 
 Rainer
 
 
 --
>> <#secure method=pgpmime mode=sign>
>> 
> <#secure method=pgpmime mode=sign>
> 
> -- 
> Rainer M. Krug
> 
> email: RMKruggmailcom
> 
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] ASCII art in function documentation?

2013-09-05 Thread Rainer M Krug
"Brian G. Peterson"  writes:

> On 09/05/2013 09:10 AM, Rainer M Krug wrote:
>>   want to include ascii art in a function documentation which should
>> look as follow:
>>
>> ,
>> | +--+--+--+
>> | | 1/16 | 1/16 | 1/16 |
>> | +--+--+--+
>> | | 1/16 | 8/16 | 1/16 |
>> | +--+--+--+
>> | | 1/16 | 1/16 | 1/16 |
>> | +--+--+--+
>> `
>>
>>
>> to keep the monospaced font even in html, I decided to use \code{}:
>
> Wouldn't it be best to use the relatively new \figure markup with
> alternate text?
>
> http://cran.r-project.org/doc/manuals/R-exts.html#Figures

Thanks - mus't have overlooked it.

This would definitely work, but in this case I think ASCII art would be
the better solution.

Thanks,

Rainer

>
> Regards,
>
> Brian
<#secure method=pgpmime mode=sign>

-- 
Rainer M. Krug

email: RMKruggmailcom

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Comments requested on "changedFiles" function

2013-09-05 Thread Karl Millar
Comments inline:


On Wed, Sep 4, 2013 at 6:10 PM, Duncan Murdoch  wrote:
>
> On 13-09-04 8:02 PM, Karl Millar wrote:
>>
>> Hi Duncan,
>>
>> I think this functionality would be much easier to use and understand if
>> you split it up the functionality of taking snapshots and comparing them
>> into separate functions.
>
>
> Yes, that's another possibility.  Some more comment below...
>
>
>
>  In addition, the 'timestamp' functionality
>>
>> seems both confusing and brittle to me.  I think it would be better to
>> store file modification times in the snapshot and use those instead of
>> an external file.  Maybe:
>
>
> You can do that, using file.info = "mtime", but the file.info snapshots are 
> quite a bit slower than using the timestamp file (when looking at a big 
> recursive directory of files).


Sorry, I completely failed to explain what I was thinking here.  There
are a number of issues here, but the biggest one is that you're
implicitly assuming that files that get modified will have mtimes that
come after the timestamp file was created.  This isn't always true,
with the most notable exception being if you download a package from
CRAN and untar it, the mtimes are usually well in the past (at least
with GNU tar on a linux system), so this code won't notice that the
files have changed.

It may be a good idea to store the file sizes as well, which would
help prevent false negatives in the (rare IIRC) cases where the
contents have changed but the mtime values have not.  Since you
already need to call file.info() to get the mtime, this shouldn't
increase the runtime, and the extra memory needed is fairly modest.

>>
>> # Take a snapshot of the files.
>> takeFileSnapshot(directory, file.info  = TRUE, md5sum
>>
>> = FALSE, full.names = FALSE, recursive = TRUE, ...)
>>
>> # Take a snapshot using the same options as used for snapshot.
>> retakeFileSnapshot(snapshot, directory = snapshot$directory) {
>> takeFileSnapshot)(directory, file.info  =
>> snapshot$file.info , md5sum = snapshot$md5sum, etc)
>>
>> }
>>
>> compareFileSnapshots(snapshot1, snapshot2)
>> - or -
>> getNewFiles(snapshat1, snapshot2)   # These names are probably too
>> generic
>> getDeletedFiles(snapshot1, snapshot2)
>> getUpdatedFiles(snapshot1, snapshot2)
>> -or-
>> setdiff(snapshot1, snapshot2)  # Unclear how this should treat updated files
>>
>>
>> This approach does have the difficulty that users could attempt to
>> compare snapshots that were taken with different options and that can't
>> be compared, but that should be an easy error to detect.
>
>
> I don't want to add too many new functions.  The general R style is to have 
> functions that do a lot, rather than have a lot of different functions to 
> achieve different parts of related tasks.  This is better for interactive use 
> (fewer functions to remember, a simpler help system to navigate), though it 
> probably results in less readable code.


This is somewhat more nuanced and not particular to interactive use
IMHO.  Having functions that do a lot is good, _as long as the
semantics are always consistent_.  For example, lm() does a huge
amount and has a wide variety of ways that you can specify your data,
but it basically does the same thing no matter how you use it.  On the
other hand, if you have a function that does different things
depending on how you call it (e.g. reshape()) then it's easy to
remember the function name, but much harder to remember how to call it
correctly, harder to understand the documentation and less readable.

>
> I can see an argument for two functions (a get and a compare), but I don't 
> think there are many cases where doing two gets and comparing the snapshots 
> would be worth the extra runtime.  (It's extra because file.info is only a 
> little faster than list.files, and it would be unavoidable to call both twice 
> in that version.  Using the timestamp file avoids one of those calls, and 
> replaces the other with file_test, which takes a similar amount of time.  So 
> overall it's about 20-25% faster.)  It also makes the code a bit more 
> complicated, i.e. three calls (get, get, compare) instead of two (get, 
> compare).


I think a 'snapshotDirectory' and 'compareDirectoryToSnapshot'
combination might work well.

Thanks,

Karl

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel