[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 murdoch.dun...@gmail.com 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}{
The path to record, or a previous snapshot.  See the Details.
}
   \item{timestamp}{
The name of 

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, 

,
| /p
| pcode +--+--+--+ br | 1/16 | 1/16 | 1/16 |
|   br +--+--+--+ br | 1/16 | 8/16 | 1/16 | br
|   +--+--+--+ br | 1/16 | 1/16 | 1/16 | br
|   +--+--+--+ br /code
| /p
`

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 rai...@krugs.de writes:

 Sarah Goslee sarah.gos...@gmail.com 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 rai...@krugs.de 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: RMKrugatgmaildotcom

__
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 rai...@krugs.de wrote:
 Sarah Goslee sarah.gos...@gmail.com 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 rai...@krugs.de 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: RMKrugatgmaildotcom



-- 
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: RMKrugatgmaildotcom

__
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 rai...@krugs.de 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 sarah.gos...@gmail.com 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 rai...@krugs.de wrote:
 Sarah Goslee sarah.gos...@gmail.com 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 rai...@krugs.de 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: RMKrugatgmaildotcom


#secure method=pgpmime mode=sign

-- 
Rainer M. Krug

email: RMKrugatgmaildotcom

__
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 sarah.gos...@gmail.com 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 rai...@krugs.de 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: RMKrugatgmaildotcom

__
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 murdoch.dun...@gmail.com wrote:
 On 13-09-04 11:36 PM, Scott Kostyshak wrote:

 On Wed, Sep 4, 2013 at 1:53 PM, Duncan Murdoch murdoch.dun...@gmail.com
 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 = 

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 rai...@krugs.de 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, 
 
 ,
 | /p
 | pcode +--+--+--+ br | 1/16 | 1/16 | 1/16 |
 |   br +--+--+--+ br | 1/16 | 8/16 | 1/16 | br
 |   +--+--+--+ br | 1/16 | 1/16 | 1/16 | br
 |   +--+--+--+ br /code
 | /p
 `
 
 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 rai...@krugs.de writes:
 
 Sarah Goslee sarah.gos...@gmail.com 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 rai...@krugs.de 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: RMKrugatgmaildotcom
 
 __
 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 br...@braverock.com 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: RMKrugatgmaildotcom

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