[Rd] OS X PDF bug (PR#13943)

2009-09-07 Thread paul . m . mcguire . jr
par(mfrow=c(2,2))
y<-1:20
plot(y,  pch="+")
plot(y,  pch="+")
plot(y,  pch="+")
plot(y,  pch="+")

produces a pdf that is viewable in Preview (copied from the  
clipboard) but fails to print.

pch default or ="." or =3 prints.

Unfortunately pch=3 doesn't fix the mfrow=c(5,6) graph that I'm  
actually trying to print,
so the bug lies somewhere deeper.

OS X 10.4.11
R 2.9.2 GUI 1.29 Tiger build 32-bit (5464)
Laserjet 5MP

Paul McGuire

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


Re: [Rd] OS X PDF bug (PR#13943)

2009-09-07 Thread ripley
On Mon, 7 Sep 2009, paul.m.mcguire...@att.net wrote:

No graphics device is specified here: which was it?

My guess is quartz() and that this is nothing to do with R but with 
copying in Mac OS X from a quartz() window.

> par(mfrow=c(2,2))
> y<-1:20
> plot(y,  pch="+")
> plot(y,  pch="+")
> plot(y,  pch="+")
> plot(y,  pch="+")
>
> produces a pdf that is viewable in Preview (copied from the
> clipboard) but fails to print.
>
> pch default or ="." or =3 prints.
>
> Unfortunately pch=3 doesn't fix the mfrow=c(5,6) graph that I'm
> actually trying to print,
> so the bug lies somewhere deeper.

Why not use pdf()?  That works for me (but then I don't have your 
printer drivers).

> OS X 10.4.11
> R 2.9.2 GUI 1.29 Tiger build 32-bit (5464)
> Laserjet 5MP
>
> Paul McGuire

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


[Rd] R CMD INSTALL --clean

2009-09-07 Thread Romain Francois

Hello,

I am using "R CMD INSTALL --clean" so that when my package is finished 
installed, a cleanup script is executed to post-process the generated 
html index file and add some more information. The cleanup (or 
cleanup.win script eventually calls the R code below)


This works well, but it depends on the --clean switch. Is there another 
way, or can I force --clean (for example from the configure script) ?


Romain


h2 <- function( txt ){
sprintf( "%s\n", txt )
}
link <- function( txt, href ){
sprintf( '%s', href, txt )
}
line <- function( link, txt ){
sprintf( '%s\n%s\n', link, txt )
}

ooindex.file <- file.path( Sys.getenv( "R_PACKAGE_DIR" ) , "html", 
"00Index.html" )

if( file.exists( ooindex.file ) ){
# read the 00Index.html file
ooindex <- readLines( ooindex.file )
bottom <- grep( "^", ooindex)
bottom <- bottom[ length(bottom) ]

# add java specific things
txt <- paste(
'\n',
h2( "Java" ),
'\n',
line( link( "javadoc" , "../javadoc/index.html" ), "API 
documentation" ),
"\n"
 )
ooindex[ bottom ] <- txt

# write back
cat( ooindex, file = ooindex.file, sep = "\n" )
}

--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/xMdt : update on the ant package
|- http://tr.im/xHLs : R capable version of ant
`- http://tr.im/xHiZ : Tip: get java home from R with rJava

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


[Rd] some (minor) Rd issue: line breaking in \S4method within \usage{}

2009-09-07 Thread Peter Ruckdeschel
Hi,

this is perhaps not so much an issue, but as you are currently
working on the Rd parser anyway...

When you want to document specific S4 methods for an S4 generic
by \S4method{} within a \usage{} environment, and the second
(signature_list) argument is "long", be it because you use multiple
dispatch, be it because you use long class-names, (or both), one
would probably like to be able to insert line breaks within the
signature list [or at least insert line breaks at suitable places
in the corresponding generated pdf file].

AFAICS this is not possible so far, at least I get errors in
R CMD check, whenever I try something like

\S4method{}{,
}(,)

i.e. if I insert a line break in the Rd file after any item of the
signature_list argument to \S4method.

Using line breaks in the the third (argument_list) argument is not a
problem, though.

So my little RFE would be to ask you to allow some optional line
breaking mechanism for the second argument of \S4method, too,
if this is not too hard to achieve.

Best regards

Peter

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


Re: [Rd] some (minor) Rd issue: line breaking in \S4method within \usage{}

2009-09-07 Thread Duncan Murdoch

On 07/09/2009 7:27 AM, Peter Ruckdeschel wrote:

Hi,

this is perhaps not so much an issue, but as you are currently
working on the Rd parser anyway...

When you want to document specific S4 methods for an S4 generic
by \S4method{} within a \usage{} environment, and the second
(signature_list) argument is "long", be it because you use multiple
dispatch, be it because you use long class-names, (or both), one
would probably like to be able to insert line breaks within the
signature list [or at least insert line breaks at suitable places
in the corresponding generated pdf file].

AFAICS this is not possible so far, at least I get errors in
R CMD check, whenever I try something like

\S4method{}{,
}(,)

i.e. if I insert a line break in the Rd file after any item of the
signature_list argument to \S4method.

Using line breaks in the the third (argument_list) argument is not a
problem, though.

So my little RFE would be to ask you to allow some optional line
breaking mechanism for the second argument of \S4method, too,
if this is not too hard to achieve.


Do you get these errors in R-devel?  (If you'd posted a real example, 
I'd try it myself, but this is your wishlist item...)


Duncan Murdoch

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


Re: [Rd] Running two R instances at the same time

2009-09-07 Thread Andrew Piskorski
On Sat, Sep 05, 2009 at 08:31:18PM +0200, Peter Juhasz wrote:

> I don't understand how is this possible. Maybe there is an issue of
> thread-safety with the R backend, meaning that the two R *interpreter*
> instances are talking to the same backend that's capable of processing
> only one thing at a time?

No.  Particularly since there is no R "backend" involved at all, not
if you're starting up the standard R from Ubuntu 9.04 (rather than
Rserve or something else unusual).  People run multiple R processes
concurrently on the same (multi-core) machine all the time, works
fine.

> Please see http://www.perlmonks.org/?node_id=792460 for an extended
> discussion of the problem, and especially
> http://www.perlmonks.org/?node_id=793506 for excerpts of output and
> actual code.

The most likely explanation seems to be that you have a bug in your
Perl code.  Have you tried using your Perl framework to fork something
OTHER than R?  Have you tried manually starting up two R processes and
running your R code that way?  And, what is the actual R code you're
running?  You don't seem to have shown it anywhere.

-- 
Andrew Piskorski 
http://www.piskorski.com/

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


Re: [Rd] Running two R instances at the same time

2009-09-07 Thread Andrew Piskorski
On Mon, Sep 07, 2009 at 05:36:38PM +0200, Peter Juhasz wrote:

> But please see http://www.perlmonks.org/index.pl?node_id=793907 ,
> where I posted my R code in its simplest form along with an example
> run which exhibits the symptoms I originally wrote about.

Ah, your two-process serialization is probably happening during that
cenros() call then.  (You may want to run with/without that call to
confirm.)  cenros() is in the NADA package and seems to use survreg()
from the survival package.  The survival package looks bigger than
NADA and includes a bunch of C code, so perhaps one of its C
implementations is using some sort of mutex-locked system call.  If
so, it'd be interesting to know where the serialization is happening.

  http://cran.r-project.org/web/packages/NADA/index.html
  http://cran.r-project.org/web/packages/survival/index.html

You may want to run your code under strace (perhaps with -cfF) and/or
ltrace, to get a list of C-level functions that are actually being
called.  That might give you an idea of where the blocking is
occurring, and could also help the NADA or survival package
maintainers when you ask them about this.

(But, hm, haven't any of your international collaborators run across
this serialization problem before?)

-- 
Andrew Piskorski 
http://www.piskorski.com/

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


[Rd] performance of vector subscripting via character index

2009-09-07 Thread Jim Regetz

Hi all,

Using character indexing on a vector is quite fast up through vector 
length of 46340, then it suddenly it gets 3 orders of magnitude slower. 
This is true at least of the special case in which the index vector is 
the complete (though possibly out-of-order) set of vector names:


test <- function(n) {
vec <- seq_len(n)
names(vec) <- as.character(vec)
ind <- rev(names(vec))
system.time(vec[ind])
}

test(46340)
##user  system elapsed
##   0.012   0.000   0.009
test(46341)
##user  system elapsed
##  11.805   0.000  11.805


There seems to be a rebound at just over twice the value of the 
threshold above, though I'll admit I didn't have the stamina to test all 
values in between:


test(92689)
##user  system elapsed
##  48.951   0.000  48.946
test(92690)
##user  system elapsed
##   0.036   0.000   0.038


And then worse again...

test(139022)
##user  system elapsed
##   0.068   0.003   0.071
test(139023)
##user  system elapsed
## 114.239   0.000 114.279

I see this on both Ubuntu 9.04 and OS X 10.6, using R 2.9.2 in both 
cases. Has this behavior already been identified? Using 'match' instead 
of direct character indexing is a serviceable workaround ... is it in 
fact the recommended approach in this case?


Thanks,
Jim


--
James Regetz, Ph.D.
Scientific Programmer/Analyst
National Center for Ecological Analysis & Synthesis
735 State St, Suite 300
Santa Barbara, CA 93101

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


Re: [Rd] question about ... passed to two different functions

2009-09-07 Thread Charles Geyer
Many thanks to those (Martin Morgan, Duncan Murdoch) who tried to straighten
me out on ... arguments.  It didn't work until I accidentally made two examples
I thought were the same but one worked and the other didn't.  Finally I
achieved enlightenment.  The following section has been added to the
help page for the metrop function and will appear on CRAN when I get finished
with the simulated tempering function.

\section{Warning}{
If \code{outfun} is missing or not a function, then the log unnormalized
density can be defined without a \ldots argument and that works fine.
One can define it starting \code{ludfun <- function(state)} and that works
or \code{ludfun <- function(state, foo, bar)}, where \code{foo} and \code{bar}
are supplied as additional arguments to \code{metrop}.

If \code{outfun} is a function, then both it and the log unnormalized
density function can be defined without \ldots arguments \emph{if they
have exactly the same arguments list} and that works fine.  Otherwise it
doesn't work.  Start the definitions \code{ludfun <- function(state, foo)}
and \code{outfun <- function(state, bar)} and you get an error about
unused arguments.  Instead start the definitions
\code{ludfun <- function(state, foo, \ldots)}
and \code{outfun <- function(state, bar, \ldots)}, supply
\code{foo} and \code{bar} as additional arguments to \code{metrop},
and that works fine.

In short, the log unnormalized density function and \code{outfun} need
to have \ldots in their arguments list to be safe.  Sometimes it works
when \ldots is left out and sometimes it doesn't.

Of course, one can avoid this whole issue by always defining the log
unnormalized density function and \code{outfun} to have only one argument
\code{state} and use global variables (objects in the R global environment) to
specify any other information these functions need to use.  That too
follows the R way.  But some people consider that bad programming practice.
}

I hope that sums it up.  Apologies for submitting a rather stupid question
to the list.
-- 
Charles Geyer
Professor, School of Statistics
University of Minnesota
char...@stat.umn.edu

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