Re: [Rd] strange error with rw2010dev

2005-04-11 Thread Martin Maechler
 Kjetil == Kjetil Brinchmann Halvorsen [EMAIL PROTECTED]
 on Sun, 10 Apr 2005 14:00:52 -0400 writes:

Kjetil The error reported below still occurs in todays
Kjetil (2005-04-08) rw2010beta, should I file a formal bug
Kjetil report?

Thank you, Kjetil.

It seems nobody has found time to look at this in the mean time.
However,
I can confirm the bug on quite a different platform
(Linux Redhat 64-bit on AMD 64).
The problem is infinite recursion which you see more easily,
when you set something like options(expressions=500).

Further note that the bug is not new, it also happens in
previous versions of R ( - i.e. no reason to stop using R 2.1.0 beta!)

Here's a ``pure script''

testmat - matrix(1:80, 20,4)
dim(testmat)
#
testframe - data.frame(testmat=I(testmat),
x=rnorm(20), y=rnorm(20), z=sample(1:20))
str(testframe)

options(expressions=100)
summary(testframe)
## Error: evaluation nested too deeply: infinite recursion / 
options(expression=)?
## -- or --
## Error: protect(): protection stack overflow


### In the second case, I at least get a useful trace back:

traceback() ## longish output, shows the infinite recursion:

..
...

17: summary.data.frame(data.frame(object), ...)
16: summary.matrix(object, digits = digits, ...)
15: summary.default(X[[1]], ...)
14: FUN(X[[1]], ...)
13: lapply(as.list(object), summary, maxsum = maxsum, digits = 12, 
...)
12: summary.data.frame(data.frame(object), ...)
11: summary.matrix(object, digits = digits, ...)
10: summary.default(X[[1]], ...)
9: FUN(X[[1]], ...)
8: lapply(as.list(object), summary, maxsum = maxsum, digits = 12, 
   ...)
7: summary.data.frame(data.frame(object), ...)
6: summary.matrix(object, digits = digits, ...)
5: summary.default(X[[1]], ...)
4: FUN(X[[1]], ...)
3: lapply(as.list(object), summary, maxsum = maxsum, digits = 12, 
   ...)
2: summary.data.frame(testframe)
1: summary(testframe)



Thanks again for the report;
this should be fixable before release.

Martin

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


Re: [Rd] strange error with rw2010dev

2005-04-11 Thread Peter Dalgaard
Martin Maechler [EMAIL PROTECTED] writes:

  Kjetil == Kjetil Brinchmann Halvorsen [EMAIL PROTECTED]
  on Sun, 10 Apr 2005 14:00:52 -0400 writes:
 
 Kjetil The error reported below still occurs in todays
 Kjetil (2005-04-08) rw2010beta, should I file a formal bug
 Kjetil report?
 
 Thank you, Kjetil.
 
 It seems nobody has found time to look at this in the mean time.
 However,
 I can confirm the bug on quite a different platform
 (Linux Redhat 64-bit on AMD 64).
 The problem is infinite recursion which you see more easily,
 when you set something like options(expressions=500).
 
 Further note that the bug is not new, it also happens in
 previous versions of R ( - i.e. no reason to stop using R 2.1.0 beta!)
 
 Here's a ``pure script''
 
 testmat - matrix(1:80, 20,4)
 dim(testmat)
 #
 testframe - data.frame(testmat=I(testmat),
 x=rnorm(20), y=rnorm(20), z=sample(1:20))
 str(testframe)
 
 options(expressions=100)
 summary(testframe)
 ## Error: evaluation nested too deeply: infinite recursion / 
 options(expression=)?
 ## -- or --
 ## Error: protect(): protection stack overflow
 
 
 ### In the second case, I at least get a useful trace back:
 
 traceback() ## longish output, shows the infinite recursion:
 
 ..
 ...
 
 17: summary.data.frame(data.frame(object), ...)
 16: summary.matrix(object, digits = digits, ...)
 15: summary.default(X[[1]], ...)
 14: FUN(X[[1]], ...)
 13: lapply(as.list(object), summary, maxsum = maxsum, digits = 12, 
 ...)
 12: summary.data.frame(data.frame(object), ...)
 11: summary.matrix(object, digits = digits, ...)
 10: summary.default(X[[1]], ...)
 9: FUN(X[[1]], ...)
 8: lapply(as.list(object), summary, maxsum = maxsum, digits = 12, 
...)
 7: summary.data.frame(data.frame(object), ...)
 6: summary.matrix(object, digits = digits, ...)
 5: summary.default(X[[1]], ...)
 4: FUN(X[[1]], ...)
 3: lapply(as.list(object), summary, maxsum = maxsum, digits = 12, 
...)
 2: summary.data.frame(testframe)
 1: summary(testframe)
 
 
 
 Thanks again for the report;
 this should be fixable before release.

Preferably before code freeze! (today)

I think we (Thomas L.?) got it analysed once before: The issue is that
summary.matrix is passing data.frame(object) back to
summary.data.frame without removing the AsIs class.

I don't a simple unclass() will do here. 

-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

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


Re: [Rd] strange error with rw2010dev

2005-04-11 Thread Martin Maechler
 PD == Peter Dalgaard [EMAIL PROTECTED]
 on 11 Apr 2005 09:46:11 +0200 writes:

 .

 MM Thanks again for the report; this should be fixable
 MM before release.

PD Preferably before code freeze! (today)

PD I think we (Thomas L.?) got it analysed once before: The
PD issue is that summary.matrix is passing
PD data.frame(object) back to summary.data.frame without
PD removing the AsIs class.

PD I don't a simple unclass() will do here.
   
or, a bit more cautiously,

summary.matrix - function(object, ...)
summary.data.frame(data.frame(if(inherits(object,AsIs)) unclass(object)
else object), ...)

That does cure the problem in the Kjetil's example and the equivalent

 ## short 1-liner:
 summary(df - data.frame(mat = I(matrix(1:8, 2


I'm currently make-checking the above.
Martin

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


Re: [Rd] strange error with rw2010dev

2005-04-11 Thread Prof Brian Ripley
On Mon, 11 Apr 2005, Martin Maechler wrote:
PD == Peter Dalgaard [EMAIL PROTECTED]
on 11 Apr 2005 09:46:11 +0200 writes:
.
MM Thanks again for the report; this should be fixable
MM before release.
   PD Preferably before code freeze! (today)
   PD I think we (Thomas L.?) got it analysed once before: The
   PD issue is that summary.matrix is passing
   PD data.frame(object) back to summary.data.frame without
   PD removing the AsIs class.
   PD I don't a simple unclass() will do here.
or, a bit more cautiously,
summary.matrix - function(object, ...)
   summary.data.frame(data.frame(if(inherits(object,AsIs)) unclass(object)
   else object), ...)
I do not think that is correct.  You need either to remove the AsIs 
class and leave any other classes, or unclass all objects.
Otherwise adding an AsIs class will change the behaviour.

I would suggest that if you get to the summary.matrix method you want the 
summary as a matrix and so should always unclass, but that is debatable 
(think for example of an object of class c(mts, ts), which is a 
classed matrix, and there is an as.data.frame.ts method but no 
summary.ts).

--
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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] strange error with rw2010dev

2005-04-10 Thread Kjetil Brinchmann Halvorsen
The error reported below still occurs in todays (2005-04-08)  rw2010beta,
should I file a formal bug report?
Kjetil.
Kjetil Brinchmann Halvorsen wrote:
With rw2010dev I get a strange  protect(): protection stack overflow
error with a small data frame which otherwise is usable:
If anybody wants to have a look I can provide an RData file
with the problematic data frame.
Doesn't seem to be necessary, the following simulated example
generates the error:
 testmat - matrix(1:80, 20,4)
 dim(testmat)
[1] 20  4
 str(testmat)
int [1:20, 1:4] 1 2 3 4 5 6 7 8 9 10 ...
 testframe - data.frame(testmat=I(testmat),
   x=rnorm(20), y=rnorm(20), z=sample(1:20))
 str(testframe)
`data.frame':   20 obs. of  4 variables:
$ testmat: int [1:20, 1:4] 1 2 3 4 5 6 7 8 9 10 ...
 ..- attr(*, class)= chr AsIs
$ x  : num   0.768 -0.462  0.450  0.476 -1.077 ...
$ y  : num   0.453  1.227 -1.514 -0.904 -0.129 ...
$ z  : int  10 4 15 19 14 3 9 17 18 5 ...
 summary(testframe)
Error: protect(): protection stack overflow
Kjetil

--
Kjetil Halvorsen.
Peace is the most effective weapon of mass construction.
  --  Mahdi Elmandjra


--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
__
R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] strange error with rw2010dev

2005-03-28 Thread Thomas Lumley
On Mon, 28 Mar 2005, Kjetil Brinchmann Halvorsen wrote:
testmat - matrix(1:80, 20,4)
dim(testmat)
[1] 20  4
str(testmat)
int [1:20, 1:4] 1 2 3 4 5 6 7 8 9 10 ...
testframe - data.frame(testmat=I(testmat),
  x=rnorm(20), y=rnorm(20), z=sample(1:20))
str(testframe)
`data.frame':   20 obs. of  4 variables:
$ testmat: int [1:20, 1:4] 1 2 3 4 5 6 7 8 9 10 ...
..- attr(*, class)= chr AsIs
$ x  : num   0.768 -0.462  0.450  0.476 -1.077 ...
$ y  : num   0.453  1.227 -1.514 -0.904 -0.129 ...
$ z  : int  10 4 15 19 14 3 9 17 18 5 ...
summary(testframe)
Error: protect(): protection stack overflow
Yes, you're getting infinite recursion.
summary.data.frame calls summary.matrix to handle the first column, and 
this then calls summary.data.frame on data.frame(testframe[[1]]), but
str(data.frame(testframe[[1]]))
`data.frame':   20 obs. of  1 variable:
 $ testframe..1..: int [1:20, 1:4] 1 2 3 4 5 6 7 8 9 10 ...
  ..- attr(*, class)= chr AsIs
so round and round we go. Perhaps summary.matrix should do something to 
remove the AsIs attribute?

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