Re: [Rd] SVN-REVSION altered when building R-devel out of tree from last snapshot

2005-12-20 Thread Martin Maechler
> "Herve" == Herve Pages <[EMAIL PROTECTED]>
> on Mon, 19 Dec 2005 17:10:58 -0800 writes:

Herve> Hi,
Herve> Today I downloaded and compiled the last R-devel snapshot.
Herve> The SVN-REVISION in the tarball contains the following:

Herve> Revision: 36792
Herve> Last Changed Date: 2005-12-18

Herve> But after compiling on Unix (I compiled out of tree), 

i.e. "in a separate build directory tree"

Herve> I ended up with an SVN-REVSION file containing:

Herve> Revision: unknown
Herve> Last Changed Date: Today

Herve> in the build tree.

I can confirm this wrong behavior (Linux Redhat EL4).
There must be something not yet perfect in our 'make' setup
there.  If we are not in the srcdir, we create a 'non-tarball'
file which I think is wrong;  in any case, this is buglet we'll fix.

Thank you, Herve!

Herve> Then when I start R, I get:

Herve> R : Copyright Today, The R Foundation for Statistical Computing
Herve> Version 2.3.0 Under development (unstable) (Today-Today-Today)
Herve> ISBN 3-900051-07-0

Herve> even if I naively edit the SVN-REVISION in the build tree before to
Herve> start R.

Herve> I got this problem on a 64-bit SUSE Linux 9.2, a 32-bit SUSE Linux 
9.2
Herve> and a Solaris 2.9 sparc system.
Herve> On Windows however (where I built R directly in the source tree) I 
don't
Herve> have this problem.

Herve> We need to update R-devel on our various build machines in order to 
test
Herve> Bioconductor devel packages with last R-devel and we try to have the 
exact
Herve> same R revision number on every test-machine. Last time I updated 
R-devel
Herve> was 12/01/2005 and I used the same procedure that I

[ you mean 12th of January? ;-)  {yes, it would help to use
  international 2005-12-01 or then Dec 01, 2005}
]

Herve> am using today but
Herve> I didn't have the SVN-REVISION problem.

Herve> Also I didn't try to build R-devel from SVN. Maybe
Herve> this could solve the problem.

that would definitely solve it, since that's what all of R-core
do "all the time".  
But the way you did, should also work; that's what the tarballs
are for!

Herve> It's just that using the tarball was easier to manage.
Herve> Anyway I thought it might be worth reporting.

Definitely.
Thank you again, Hervé !

Herve> Regards,

Herve> Hervé
 

Herve> -- 
Herve> 
Herve> Hervé Pagès
Herve> E-mail: [EMAIL PROTECTED]
Herve> Phone: (206) 667-5791
Herve> Fax: (206) 667-1319

Herve> __
Herve> R-devel@r-project.org mailing list
Herve> 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] Overlaying lattice plots

2005-12-20 Thread ernesto
Hillary, Richard M wrote:

> Morning chaps, I have a little question for your capable minds... Say
> I have an observed and predicted set of quants (in my case, length
> frequencies by year and age/length), is there a way to use lattice
> plots to plot the observed and predicted data together, panel by panel?
> Obrigado/gracias (thankyou in Galego is?...)
> Rich

Hi Richard,

If you want to plot both datasets on the same plot just make use of the
xyplot for FLQuants, something like

flqs <- FLQuants(list(pred=pred.quant, res=res.quant))
xyplot(data~age, data=flqs)

now tune it the way you want and change the formula to fit your needs.

Regards

EJ

ps: I'm cc'ing this to the mailing lists, I find it usefull for others.

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


Re: [Rd] Overlaying lattice plots

2005-12-20 Thread Hillary, Richard M
Excellent, thanks man!
Rich 

-Original Message-
From: ernesto [mailto:[EMAIL PROTECTED] 
Sent: 20 December 2005 10:32
To: Hillary, Richard M; Iago Mosqueira; Mailing List R; R-devel
Subject: Re: Overlaying lattice plots

Hillary, Richard M wrote:

> Morning chaps, I have a little question for your capable minds... Say 
> I have an observed and predicted set of quants (in my case, length 
> frequencies by year and age/length), is there a way to use lattice 
> plots to plot the observed and predicted data together, panel by
panel?
> Obrigado/gracias (thankyou in Galego is?...) Rich

Hi Richard,

If you want to plot both datasets on the same plot just make use of the
xyplot for FLQuants, something like

flqs <- FLQuants(list(pred=pred.quant, res=res.quant)) xyplot(data~age,
data=flqs)

now tune it the way you want and change the formula to fit your needs.

Regards

EJ

ps: I'm cc'ing this to the mailing lists, I find it usefull for others.

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


Re: [Rd] Overlaying lattice plots - SORRY, WRONG MAILING LIST ADDRESS

2005-12-20 Thread ernesto
ernesto wrote:

>Hillary, Richard M wrote:
>
>  
>
>>Morning chaps, I have a little question for your capable minds... Say
>>I have an observed and predicted set of quants (in my case, length
>>frequencies by year and age/length), is there a way to use lattice
>>plots to plot the observed and predicted data together, panel by panel?
>>Obrigado/gracias (thankyou in Galego is?...)
>>Rich
>>
>>
>
>Hi Richard,
>
>If you want to plot both datasets on the same plot just make use of the
>xyplot for FLQuants, something like
>
>flqs <- FLQuants(list(pred=pred.quant, res=res.quant))
>xyplot(data~age, data=flqs)
>
>now tune it the way you want and change the formula to fit your needs.
>
>Regards
>
>EJ
>
>ps: I'm cc'ing this to the mailing lists, I find it usefull for others.
>  
>

Hi,

Sorry for this message, wrong address. I wanted to send it to
FLR-mailing list.

Regards

EJ

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


Re: [Rd] Overlaying lattice plots

2005-12-20 Thread Hillary, Richard M
There seems to be a problem here, probably of my own making... 

flqs <- FLQuants(list(observed=obs, fitted=fits))
xyplot(data~age,data=flqs)
Error in tmp[subset] : object is not subsettable
? 

-Original Message-
From: ernesto [mailto:[EMAIL PROTECTED] 
Sent: 20 December 2005 10:32
To: Hillary, Richard M; Iago Mosqueira; Mailing List R; R-devel
Subject: Re: Overlaying lattice plots

Hillary, Richard M wrote:

> Morning chaps, I have a little question for your capable minds... Say 
> I have an observed and predicted set of quants (in my case, length 
> frequencies by year and age/length), is there a way to use lattice 
> plots to plot the observed and predicted data together, panel by
panel?
> Obrigado/gracias (thankyou in Galego is?...) Rich

Hi Richard,

If you want to plot both datasets on the same plot just make use of the
xyplot for FLQuants, something like

flqs <- FLQuants(list(pred=pred.quant, res=res.quant)) xyplot(data~age,
data=flqs)

now tune it the way you want and change the formula to fit your needs.

Regards

EJ

ps: I'm cc'ing this to the mailing lists, I find it usefull for others.

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


[Rd] 2 x 2 chisq.test (PR#8415)

2005-12-20 Thread cig69410
Full_Name: nobody
Version: 2.2.0
OS: any
Submission from: (NULL) (219.66.34.183)


2 x 2 table, such as

> x
 [,1] [,2]
[1,]   10   12
[2,]   11   13

> chisq.test(x)

Pearson's Chi-squared test with Yates'
continuity correction

data:  x 
X-squared = 0.0732, df = 1, p-value = 0.7868

but, X-squared = 0.0732 is over corrected.

when abs(a*d-b*c) <= sum(a,b,c,d), chisq.value must be 0!, and P-value must be
1!

code of chisq.test must be as follows

 #   if (correct && nrow(x) == 2 && ncol(x) == 2) {
 #   YATES <- 0.5
 #   METHOD <- paste(METHOD, "with Yates' continuity correction")
 #   }
 #   else YATES <- 0
 #   STATISTIC <- sum((abs(x - E) - YATES)^2/E)
 ## replace begin
 if (correct && nrow(x) == 2 && ncol(x) == 2) {
 STATISTIC <- if (abs(x[1,1]*x[2,2]-x[1,2]*x[2,1]) < sum(x)/2) 0
   
  else sum((abs(x - E) - 0.5)^2/E)
 METHOD <- paste(METHOD, "with Yates' continuity correction")
 }
 else STATISTIC <- sum((abs(x - E))^2/E)
 ## replace end

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


Re: [Rd] 2 x 2 chisq.test (PR#8415)

2005-12-20 Thread ripley
This is the same as PR#8265, from a person also not giving his/her name 
but sharing your ISP.  Please don't submit a repeat, as the FAQ asks.

After last time this was raised, I checked Yates' original paper and 
Fisher's book and it seems that R's formula follows what they say.

Do remember that 0 is an impossible value for a chisq-distributed 
variable, and so one would not expect the corrected distribution to take 
that value with positive probability.

On Tue, 20 Dec 2005 [EMAIL PROTECTED] wrote:

> Full_Name: nobody

Do you expect us to take the word of `nobody' as to the correct definition 
of a statistic?  We need your credentials and references.

> Version: 2.2.0
> OS: any
> Submission from: (NULL) (219.66.34.183)
>
>
> 2 x 2 table, such as
>
>> x
> [,1] [,2]
> [1,]   10   12
> [2,]   11   13
>
>> chisq.test(x)
>
>   Pearson's Chi-squared test with Yates'
>   continuity correction
>
> data:  x
> X-squared = 0.0732, df = 1, p-value = 0.7868
>
> but, X-squared = 0.0732 is over corrected.
>
> when abs(a*d-b*c) <= sum(a,b,c,d), chisq.value must be 0!, and P-value must be
> 1!
>
> code of chisq.test must be as follows
>
> #   if (correct && nrow(x) == 2 && ncol(x) == 2) {
> #   YATES <- 0.5
> #   METHOD <- paste(METHOD, "with Yates' continuity correction")
> #   }
> #   else YATES <- 0
> #   STATISTIC <- sum((abs(x - E) - YATES)^2/E)
> ## replace begin
> if (correct && nrow(x) == 2 && ncol(x) == 2) {
> STATISTIC <- if (abs(x[1,1]*x[2,2]-x[1,2]*x[2,1]) < sum(x)/2) > 0
>
>  else sum((abs(x - E) - 0.5)^2/E)
> METHOD <- paste(METHOD, "with Yates' continuity correction")
> }
> else STATISTIC <- sum((abs(x - E))^2/E)
> ## replace end

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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] 2 x 2 chisq.test (PR#8415)

2005-12-20 Thread Thomas Lumley

This is the same as PR#8265, which was reported two months ago by someone 
else from syd.odn.ne.jp.  It still isn't a bug. According to Brian 
Ripley's response at that time, "almost all" the sources he checked gave 
the correction that R uses.

-thomas

On Tue, 20 Dec 2005, [EMAIL PROTECTED] wrote:

> Full_Name: nobody
> Version: 2.2.0
> OS: any
> Submission from: (NULL) (219.66.34.183)
>
>
> 2 x 2 table, such as
>
>> x
> [,1] [,2]
> [1,]   10   12
> [2,]   11   13
>
>> chisq.test(x)
>
>   Pearson's Chi-squared test with Yates'
>   continuity correction
>
> data:  x
> X-squared = 0.0732, df = 1, p-value = 0.7868
>
> but, X-squared = 0.0732 is over corrected.
>
> when abs(a*d-b*c) <= sum(a,b,c,d), chisq.value must be 0!, and P-value must be
> 1!
>
> code of chisq.test must be as follows
>
> #   if (correct && nrow(x) == 2 && ncol(x) == 2) {
> #   YATES <- 0.5
> #   METHOD <- paste(METHOD, "with Yates' continuity correction")
> #   }
> #   else YATES <- 0
> #   STATISTIC <- sum((abs(x - E) - YATES)^2/E)
> ## replace begin
> if (correct && nrow(x) == 2 && ncol(x) == 2) {
> STATISTIC <- if (abs(x[1,1]*x[2,2]-x[1,2]*x[2,1]) < sum(x)/2) > 0
>
>  else sum((abs(x - E) - 0.5)^2/E)
> METHOD <- paste(METHOD, "with Yates' continuity correction")
> }
> else STATISTIC <- sum((abs(x - E))^2/E)
> ## replace end
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

Thomas Lumley   Assoc. Professor, Biostatistics
[EMAIL PROTECTED]   University of Washington, Seattle

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


[Rd] Problems with Windows Cross compile

2005-12-20 Thread Warnes, Gregory R

Well, I'm finally getting around to setting up a cross-compiler for Windows on 
my local Linux box.   I'm using the Yan & Rossini's docuimentation and the 
latest 'http://cran.r-project.org/doc/contrib/Makefile-rcb' , which is working 
of the R-2.2.0 sources.

After discovering that "cp -p" doesn't work on the filesystem I'm using and 
removing the '-p's in the R makefiles using perl, I've gotten things to run 
pretty far through.  Unfortunately, I get stopped by this error when building 
the base packages:

writing help indices for package: base tools utils grDevices graphics 
stats datasets methods grid splines stats4 tcltk

-- Making package base 
  adding build stamp to DESCRIPTION
  installing inst files
  installing indices
Error in get(x, envir, mode, inherits) : variable "win.packages.html" 
was not found
Execution halted

Any ideas?

-Greg

Gregory R. Warnes, Ph.D.
Associate Director, Non-Clinical Statistics
Pfizer Global Research and Development

--
LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}}

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


[Rd] pmin(), pmax() - slower than necessary for common cases

2005-12-20 Thread Martin Maechler
A few hours ago, I was making a small point on the R-SIG-robust
mailing list on the point that  ifelse() was not too efficient
in a situation where  pmax() could easily be used instead.

However, this has reminded me of some timing experiments that I
did 13 years ago with S-plus -- where I found that pmin() /
pmax() were really relatively slow for the most common case
where they are used with only two arguments {and typically one
of the arguments is a scalar; but that's not even important here}.
The main reason is that the function accept an arbitrary number
of arguments and that they do recycling.
Their source is at
  https://svn.R-project.org/R/trunk/src/library/base/R/pmax.R

In April 2001 (as I see), I had repeated my timings with R (1.2.2)
which confirmed the picture more or less,  but for some reason I
never drew "proper" consequences of my findings.
Of course one can argue  pmax() & pmin() are still quite fast
functions; OTOH the experiment below shows that -- at least the
special case with 2 (matching) arguments could be made faster by
about a factor of 19 ...

I don't have yet a constructive proposition; just note the fact that

  pmin. <- function(k,x) (x+k - abs(x-k))/2
  pmax. <- function(k,x) (x+k + abs(x-k))/2

are probably the fastest way of computing  pmin() and pmax() of
two arguments {yes, they "suffer" from rounding error of about 1
to 2 bits...} currently in R. 
One "solution" could be to provide  pmin2() and pmax2()
functions based on trival .Internal() versions.

The experiments below are for the special case of  k=0  where I
found the above mentioned factor of 19 which is a bit
overoptimistic for the general case; here is my  pmax-ex.R  source file
(as text/plain attachment ASCII-code --> easy cut & paste)
demonstrating what I claim above.

 Martin Maechler, Aug.1992 (S+ 3.x) --- the same applies to R 1.2.2

 Observation:  (abs(x) + x) / 2  is  MUCH faster than  pmax(0,x) !!

 The function  pmax.fast below is  very slightly slower than (|x|+x)/2

### "this" directory  --- adapt!
thisDir <- "/u/maechler/R/MM/MISC/Speed"


### For R's source,
###  egrep 'pm(ax|in)'  src/library/*/R/*.R
### shows you that most uses of  pmax() / pmin() are really just with arguments
###  ( ,  )  where the fast versions would be much better!

pmax.fast <- function(scalar, vector)
{
 ## Purpose: FAST substitute for pmax(s, v) when length(s) == 1
 ## Author: Martin Maechler, Date: 21 Aug 1992 (for S)
 vector[ scalar > vector ] <- scalar
 vector
}
## 2 things:
##   1) the above also works when 'scalar' == vector of same length
##   2) The following is even (quite a bit!) faster :

pmin. <- function(k,x) (x+k - abs(x-k))/2
pmax. <- function(k,x) (x+k + abs(x-k))/2


### The following are small scale timing simulations which confirm:

N <- 20 ## number of experiment replications
kinds <- c("abs", "[.>.]<-", "Fpmax", "pmax0.", "pmax.0")
Tmat <- matrix(NA, nrow = N, ncol = length(kinds),
   dimnames = list(NULL, kinds))
T0 <- Tmat[,1] # `control group'
n.inner <- 800 # should depend on the speed of your R / S  (i.e. CPU)

set.seed(101)
for(k in 1:N) {
cat(k,"")
## no longer set.seed(101)
x <- rnorm(1000)
Tmat[k, "pmax0."] <- system.time(for(i in 1:n.inner)y <- pmax(0,x))[1]
Tmat[k, "pmax.0"] <- system.time(for(i in 1:n.inner)y <- pmax(x,0))[1]
Tmat[k,"abs"] <- system.time(for(i in 1:n.inner)y <- (x + abs(x))/2)[1]
Tmat[k,"[.>.]<-"] <- system.time(for(i in 1:n.inner)y <-{x[0 > x] <- 
0;x})[1]
Tmat[k,  "Fpmax"] <- system.time(for(i in 1:n.inner)y <- pmax.fast(0,x))[1]
}

save(Tmat, file = file.path(thisDir, "pmax-Tmat.rda"))

###-- Restart here {saving simulation/timing}:

if(!exists("Tmat"))
load(file.path(thisDir, "pmax-Tmat.rda"))

(Tm <- apply(Tmat, 2, mean, trim = .1))
##  abs  [.>.]<-Fpmax   pmax0.   pmax.0
## 0.025625 0.078750 0.077500 0.488125 0.511250
round(100 * Tm / Tm[1])
## abs [.>.]<-   Fpmax  pmax0.  pmax.0
## 100 307 30219051995
## earlier:
##  abs [.>.]<-   Fpmax  pmax0.  pmax.0
##  100 289 34418041884


## pmax0. is really a bit faster than pmax.0 :
## P < .001 (for Wilcoxon; outliers!)
t.test(Tmat[,4], Tmat[,5], paired = TRUE)
t.test(Tmat[,4], Tmat[,5], paired = FALSE)# since random samples
wilcox.test(Tmat[,4], Tmat[,5])# P = 0.00012 {but ties -> doubt}

boxplot(data.frame(Tmat, check.names = FALSE),
notch = TRUE, ylim = range(0,Tmat),
main = "CPU times used for versions of pmax(0,x)")
mtext(paste("x <- rnorm(1000)","  ", N, "replicates"), side = 3)
mtext(paste(R.version.string, file.path(thisDir, "pmax-ex.R")),
  side = 4, cex =.8, adj = 0)
## see if trimmed means were robust enough:
points(Tm, col = 2, cex = 1.5, pch = "X")
mtext("X : mean( * , trim = 0.10)", side = 1, line = -2.5, col = 2)
mtext(paste(round(100 * Tm / Tm[1]),"%"), side = 1, line = -1.2, col = 2,
  at = 1:5)


Martin Maechler, ETH Zurich

Re: [Rd] Problems with Windows Cross compile

2005-12-20 Thread Jun Yan
I've seen that error before. It has to do with the setup of R_EXE. A 
current linux R is required. The following order worked for me:

make linuxR
make LinuxFresh=YES mkrules
make R


Jun

On Tue, 20 Dec 2005, Warnes, Gregory R wrote:

>
> Well, I'm finally getting around to setting up a cross-compiler for Windows 
> on my local Linux box.   I'm using the Yan & Rossini's docuimentation and the 
> latest 'http://cran.r-project.org/doc/contrib/Makefile-rcb' , which is 
> working of the R-2.2.0 sources.
>
> After discovering that "cp -p" doesn't work on the filesystem I'm using and 
> removing the '-p's in the R makefiles using perl, I've gotten things to run 
> pretty far through.  Unfortunately, I get stopped by this error when building 
> the base packages:
>
>   writing help indices for package: base tools utils grDevices graphics 
> stats datasets methods grid splines stats4 tcltk
>
>   -- Making package base 
> adding build stamp to DESCRIPTION
> installing inst files
> installing indices
>   Error in get(x, envir, mode, inherits) : variable "win.packages.html" 
> was not found
>   Execution halted
>
> Any ideas?
>
> -Greg
>
> Gregory R. Warnes, Ph.D.
> Associate Director, Non-Clinical Statistics
> Pfizer Global Research and Development
>
> --
> LEGAL NOTICE
> Unless expressly stated otherwise, this message is confidential and may be 
> privileged.  It is intended for the addressee(s) only.  Access to this E-mail 
> by anyone else is unauthorized.  If you are not an addressee, any disclosure 
> or copying of the contents of this E-mail or any action taken (or not taken) 
> in reliance on it is unauthorized and may be unlawful.  If you are not an 
> addressee, please inform the sender immediately.
>

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


Re: [Rd] Problems with Windows Cross compile

2005-12-20 Thread Warnes, Gregory R
Thanks, the default version of R here is 2.1.0, so that must have been the 
problem.  Everything is working now. 

-Greg

> -Original Message-
> From: Jun Yan [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, December 20, 2005 1:07 PM
> To: Warnes, Gregory R
> Cc: R-devel (E-mail); Anthony Rossini (E-mail)
> Subject: Re: Problems with Windows Cross compile
> 
> 
> I've seen that error before. It has to do with the setup of R_EXE. A 
> current linux R is required. The following order worked for me:
> 
> make linuxR
> make LinuxFresh=YES mkrules
> make R
> 
> 
> Jun
> 
> On Tue, 20 Dec 2005, Warnes, Gregory R wrote:
> 
> >
> > Well, I'm finally getting around to setting up a 
> cross-compiler for Windows on my local Linux box.   I'm using 
> the Yan & Rossini's docuimentation and the latest 
> 'http://cran.r-project.org/doc/contrib/Makefile-rcb' , which 
> is working of the R-2.2.0 sources.
> >
> > After discovering that "cp -p" doesn't work on the 
> filesystem I'm using and removing the '-p's in the R 
> makefiles using perl, I've gotten things to run pretty far 
> through.  Unfortunately, I get stopped by this error when 
> building the base packages:
> >
> > writing help indices for package: base tools utils 
> grDevices graphics stats datasets methods grid splines stats4 tcltk
> >
> > -- Making package base 
> >   adding build stamp to DESCRIPTION
> >   installing inst files
> >   installing indices
> > Error in get(x, envir, mode, inherits) : variable 
> "win.packages.html" was not found
> > Execution halted
> >
> > Any ideas?
> >
> > -Greg
> >
> > Gregory R. Warnes, Ph.D.
> > Associate Director, Non-Clinical Statistics
> > Pfizer Global Research and Development
> >
> > 
> --
> > LEGAL NOTICE
> > Unless expressly stated otherwise, this message is 
> confidential and may be privileged.  It is intended for the 
> addressee(s) only.  Access to this E-mail by anyone else is 
> unauthorized.  If you are not an addressee, any disclosure or 
> copying of the contents of this E-mail or any action taken 
> (or not taken) in reliance on it is unauthorized and may be 
> unlawful.  If you are not an addressee, please inform the 
> sender immediately.
> >
> 
--
LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}}

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


[Rd] suggestion: link oneway.test on kruskal.test page

2005-12-20 Thread P Ehlers
DevelopeRs:

I think it might be useful to add a link to oneway.test() on
the kruskal.test() help page.

("R version 2.3.0, 2005-12-09")

Peter Ehlers
U of Calgary

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


[Rd] NextMethod causes R 2.2.0 to crash (PR#8416)

2005-12-20 Thread Bill . Venables
I found writing the following default method the for the generic
function "julian" causes R to crash.


julian.default <- function(x, ...) {
x <- as.Date(x)
NextMethod("julian", x, ...)
}

Here is a test example 

> m <- as.Date("1972-09-27") + 0:10
> m 
 [1] "1972-09-27" "1972-09-28" "1972-09-29" "1972-09-30" "1972-10-01"
"1972-10-02" "1972-10-03"
 [8] "1972-10-04" "1972-10-05" "1972-10-06" "1972-10-07"
> class(m)
[1] "Date"
> julian(m)
 [1] 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010
attr(,"origin")
[1] "1970-01-01"

> m <- as.character(m)
> class(m)
[1] "character"

> julian(m)

< R crashes>

--please do not edit the information below--

Version:
 platform = i386-pc-mingw32
 arch = i386
 os = mingw32
 system = i386, mingw32
 status = 
 major = 2
 minor = 2.0
 year = 2005
 month = 10
 day = 06
 svn rev = 35749
 language = R



Bill Venables, 
CMIS, CSIRO Laboratories, 
PO Box 120, Cleveland, Qld. 4163 
AUSTRALIA 
Office Phone (email preferred): +61 7 3826 7251 
Fax (if absolutely necessary):+61 7 3826 7304 
Mobile (rarely used):+61 4 1963 4642 
Home Phone:  +61 7 3286 7700 
mailto:[EMAIL PROTECTED] 
http://www.cmis.csiro.au/bill.venables/

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


Re: [Rd] NextMethod causes R 2.2.0 to crash (PR#8416)

2005-12-20 Thread Henrik Bengtsson
[EMAIL PROTECTED] wrote:
> I found writing the following default method the for the generic
> function "julian" causes R to crash.
> 
> 
> julian.default <- function(x, ...) {
> x <- as.Date(x)
> NextMethod("julian", x, ...)
> }

On Windows XP R 2.2.0 Patched (2005-11-21 r36410) you get:

Error: evaluation nested too deeply: infinite recursion / 
options(expressions=)?

and on Windows XP R 2.1.1 Patched (2005-09-19) you get:

Error: protect(): protection stack overflow

It seems that the R.2.2.0 revision you have does not protect against 
this.  I agree that it should not be possible to crash R, but is it 
valid to call NextMethod() in a default function? [R core, should this 
ever be allowed?]

I do not know exactly how NextMethod() is expected to work here, but I 
could imaging that 'x' has class 'Date' when NextMethod() is called and 
the "next" class will the be the default one so you call 
julian.default() again ending up in an infinite call.  This makes sense 
from the errors I get above.  Try this and see what you get in your version:

julian.default <- function(x, ...) {
   cat("In julian.default()\n")
   x <- as.Date(x)
   NextMethod("julian", x, ...)
}

Was you intention to do the following instead

  julian.default <- function(x, ...) {
x <- as.Date(x)
julian(x, ...)
  }

where julian() is the generic function?

Cheers

Henrik


> Here is a test example 
> 
> 
>>m <- as.Date("1972-09-27") + 0:10
>>m 
> 
>  [1] "1972-09-27" "1972-09-28" "1972-09-29" "1972-09-30" "1972-10-01"
> "1972-10-02" "1972-10-03"
>  [8] "1972-10-04" "1972-10-05" "1972-10-06" "1972-10-07"
> 
>>class(m)
> 
> [1] "Date"
> 
>>julian(m)
> 
>  [1] 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010
> attr(,"origin")
> [1] "1970-01-01"
> 
> 
>>m <- as.character(m)
>>class(m)
> 
> [1] "character"
> 
> 
>>julian(m)
> 
> 
> < R crashes>
> 
> --please do not edit the information below--
> 
> Version:
>  platform = i386-pc-mingw32
>  arch = i386
>  os = mingw32
>  system = i386, mingw32
>  status = 
>  major = 2
>  minor = 2.0
>  year = 2005
>  month = 10
>  day = 06
>  svn rev = 35749
>  language = R
> 
> 
> 
> Bill Venables, 
> CMIS, CSIRO Laboratories, 
> PO Box 120, Cleveland, Qld. 4163 
> AUSTRALIA 
> Office Phone (email preferred): +61 7 3826 7251 
> Fax (if absolutely necessary):+61 7 3826 7304 
> Mobile (rarely used):+61 4 1963 4642 
> Home Phone:  +61 7 3286 7700 
> mailto:[EMAIL PROTECTED] 
> http://www.cmis.csiro.au/bill.venables/
> 
> __
> 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] NextMethod causes R 2.2.0 to crash (PR#8416)

2005-12-20 Thread Bill.Venables
Thanks Hendrik.

My main concern is that it should not be so easy to crash R.

On whether or not NextMethod from within the default method is kosher or
not - I would have thought so, but clearly I'm wrong here.  Perhaps
NextMethod within a default method should be something that at least
attracts a warning.

Regards,

Bill Venables, 
CMIS, CSIRO Laboratories, 
PO Box 120, Cleveland, Qld. 4163 
AUSTRALIA 
Office Phone (email preferred): +61 7 3826 7251 
Fax (if absolutely necessary):+61 7 3826 7304 
Mobile (rarely used):+61 4 1963 4642 
Home Phone:  +61 7 3286 7700 
mailto:[EMAIL PROTECTED] 
http://www.cmis.csiro.au/bill.venables/ 



-Original Message-
From: Henrik Bengtsson [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, 21 December 2005 1:48 PM
To: Venables, Bill (CMIS, Cleveland)
Cc: r-devel@stat.math.ethz.ch; [EMAIL PROTECTED]
Subject: Re: [Rd] NextMethod causes R 2.2.0 to crash (PR#8416)


[EMAIL PROTECTED] wrote:
> I found writing the following default method the for the generic
> function "julian" causes R to crash.
> 
> 
> julian.default <- function(x, ...) {
> x <- as.Date(x)
> NextMethod("julian", x, ...)
> }

On Windows XP R 2.2.0 Patched (2005-11-21 r36410) you get:

Error: evaluation nested too deeply: infinite recursion / 
options(expressions=)?

and on Windows XP R 2.1.1 Patched (2005-09-19) you get:

Error: protect(): protection stack overflow

It seems that the R.2.2.0 revision you have does not protect against 
this.  I agree that it should not be possible to crash R, but is it 
valid to call NextMethod() in a default function? [R core, should this 
ever be allowed?]

I do not know exactly how NextMethod() is expected to work here, but I 
could imaging that 'x' has class 'Date' when NextMethod() is called and 
the "next" class will the be the default one so you call 
julian.default() again ending up in an infinite call.  This makes sense 
from the errors I get above.  Try this and see what you get in your
version:

julian.default <- function(x, ...) {
   cat("In julian.default()\n")
   x <- as.Date(x)
   NextMethod("julian", x, ...)
}

Was you intention to do the following instead

  julian.default <- function(x, ...) {
x <- as.Date(x)
julian(x, ...)
  }

where julian() is the generic function?

Cheers

Henrik


> Here is a test example 
> 
> 
>>m <- as.Date("1972-09-27") + 0:10
>>m 
> 
>  [1] "1972-09-27" "1972-09-28" "1972-09-29" "1972-09-30" "1972-10-01"
> "1972-10-02" "1972-10-03"
>  [8] "1972-10-04" "1972-10-05" "1972-10-06" "1972-10-07"
> 
>>class(m)
> 
> [1] "Date"
> 
>>julian(m)
> 
>  [1] 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010
> attr(,"origin")
> [1] "1970-01-01"
> 
> 
>>m <- as.character(m)
>>class(m)
> 
> [1] "character"
> 
> 
>>julian(m)
> 
> 
> < R crashes>
> 
> --please do not edit the information below--
> 
> Version:
>  platform = i386-pc-mingw32
>  arch = i386
>  os = mingw32
>  system = i386, mingw32
>  status = 
>  major = 2
>  minor = 2.0
>  year = 2005
>  month = 10
>  day = 06
>  svn rev = 35749
>  language = R
> 
> 
> 
> Bill Venables, 
> CMIS, CSIRO Laboratories, 
> PO Box 120, Cleveland, Qld. 4163 
> AUSTRALIA 
> Office Phone (email preferred): +61 7 3826 7251 
> Fax (if absolutely necessary):+61 7 3826 7304 
> Mobile (rarely used):+61 4 1963 4642 
> Home Phone:  +61 7 3286 7700 
> mailto:[EMAIL PROTECTED] 
> http://www.cmis.csiro.au/bill.venables/
> 
> __
> 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