Re: [Rd] Parsing multi-line strings. Bug? Feature?

2004-07-29 Thread Prof Brian Ripley
Perhaps the two of you would like to submit a patch for consideration?
I think you can take it that it was considered in Dec 2002 and no one 
wanted to do the work to check the feasibility.

The form in Open Source projects is that those who want a feature 
implement it and offer it to the maintainers.

On Wed, 28 Jul 2004, Kevin Wright wrote:

 I have an S-Plus library that I would like to port to R.  The library 
 sends a mix of static and dynamic output to an html file.  For example
 
 cat(
 ...
 Big block of HTML formatting code
 ...
 )
 cat(dat())
 cat(
 More static text
 )
 
 With S-Plus I can just cut and paste HTML code from other files into my 
 S-Plus script file.  This makes maintenance of the script fairly easy.
 
 The R parser chokes on this and requires strings to have a backslash for 
 line continuation:
 
 f = function(){
  sometext =  abc \
 def
 }
 
 Mark Bravington discussed the same issue (with comments about
 the documentation) here:
 http://tolstoy.newcastle.edu.au/R/help/02b/5199.html
 
 I would like to echo Mark's request that compatability with S-Plus 
 be considered.
 
 Thanks
 
 Kevin Wright
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-devel
 
 

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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-devel


[Rd] cross-compile R darwin2win, almost there

2004-07-29 Thread Simon Urbanek
I'm trying to cross-compile R on a Mac OS X box to target Win32. It 
works quite well, everything works, except for one fortran file ppr.f 
in the stats package:

-- Making package stats 
  adding build stamp to DESCRIPTION
  installing NAMESPACE file and metadata
  making DLL ...
i386-mingw32-g77 -O2 -Wall   -c ppr.f -o ppr.o
ppr.f:803: sorry, unimplemented: data initializer on host with 
different endianness
ppr.f:803: sorry, unimplemented: data initializer on host with 
different endianness
ppr.f:803: sorry, unimplemented: data initializer on host with 
different endianness
ppr.f:803: sorry, unimplemented: data initializer on host with 
different endianness
ppr.f:803: sorry, unimplemented: data initializer on host with 
different endianness
ppr.f:803: sorry, unimplemented: data initializer on host with 
different endianness
ppr.f:803: sorry, unimplemented: data initializer on host with 
different endianness
ppr.f:803: sorry, unimplemented: data initializer on host with 
different endianness
ppr.f:803: sorry, unimplemented: data initializer on host with 
different endianness
ppr.f:803: sorry, unimplemented: data initializer on host with 
different endianness
ppr.f:803: sorry, unimplemented: data initializer on host with 
different endianness
ppr.f:803: sorry, unimplemented: data initializer on host with 
different endianness
ppr.f:1186: sorry, unimplemented: data initializer on host with 
different endianness
ppr.f:1186: sorry, unimplemented: data initializer on host with 
different endianness
ppr.f:1186: sorry, unimplemented: data initializer on host with 
different endianness
ppr.f:1186: sorry, unimplemented: data initializer on host with 
different endianness
make[5]: *** [ppr.o] Error 1
make[4]: *** [srcDynlib] Error 2

It's just a block data with some common variables that are 
initialized en-block. Obviously g77 tries to copy the whole block and 
bails out, because it's unsure about the endianness conversion (could 
be int/double whatever). My Fortran knowledge is rather limited, so can 
anyone provide me with alternate Fortran code that will use regular 
assignments instead of the block data, so we can work around the 
missing feature of the compiler? If someone has a different idea, 
that's fine, too :).

Otherwise it works very nicely, the compiled R works (except that stats 
is not compiled of course) ... Solving the above would allow us to 
provide binary packages for both platforms OS X and Windows using just 
one machine to automatically generate both... (for those interested I 
could put the cross-compile tools on my pages..)

Any help is appreciated,
Simon
---
Simon Urbanek
Department of computer oriented statistics and data analysis
Universitätsstr. 14
86135 Augsburg
Germany
Tel: +49-821-598-2236
Fax: +49-821-598-2280
[EMAIL PROTECTED]
http://simon.urbanek.info
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-devel


[Rd] aov for unbalanced design (PR#7144)

2004-07-29 Thread tlogvinenko
Full_Name: Tanya Logvinenko
Version: 1.7.0
OS: Windows 2000
Submission from: (NULL) (132.183.156.125)


For unbalanced design, I ran into problem with ANOVA (aov function). The sum of
squares for only for the second factor and total are computed correctly, but sum
of squares for the first factor is computed incorreclty. Changing order of
factors in the formula changes the ANOVA table. For the balanced design, there
is no such problem.

 summary(aov(data[1,]~factor1+factor2))
Df  Sum Sq Mean Sq F valuePr(F)
factor1  5 1524420  304884  6.4529 0.0003229 ***
factor2  7 1447830  206833  4.3776 0.0017808 ** 
Residuals   31 1464674   47248  
---
Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 
 summary(aov(data[1,]~factor2+factor1))
Df  Sum Sq Mean Sq F valuePr(F)
factor2  7 1648225  235461  4.9836 0.0007295 ***
factor1  5 1324025  264805  5.6046 0.0008612 ***
Residuals   31 1464674   47248  
---
Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-devel


[Rd] Re: matrix subsetting (was: [R] as(obj,matrix))

2004-07-29 Thread Patrick Burns
On a related topic, a client came up with this example
a few days ago which I was unable to explain.  (But he
did heed my advise of don't do that.)
 matrixObj - array(1:4, c(2,2))
 class(matrixObj) - matrix
 fooObj - matrixObj
 class(fooObj) - foo
 fooObj[1:2]
Testing
[,1] [,2]
[1,]13
[2,]24
attr(,class)
[1] foo
 matrixObj[1:2]
[1] 1 2
 get([.matrix)
function(x, i, j, drop = if(missing(i)) TRUE else length(cols)==1)
{   
   cat(Testing\n)
   x  
}
 get([.foo)
function(x, i, j, drop = if(missing(i)) TRUE else length(cols)==1)
{   
   cat(Testing\n)
   x  
}

Everything is the same except for the name of the class.  When
the class is matrix, it ignores the subset method.  But the very
same code works if the class is foo.  This is 1.9.1 Windows,
and the same happens with  1.7.0 (the oldest version I have on
my machine).
What is happening here?
Patrick Burns
Burns Statistics
[EMAIL PROTECTED]
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and A Guide for the Unwilling S User)
John Chambers wrote:
Wolski wrote:
 

Hi!
Here a simple example.
setClass(myclass
,representation(info=character)
,contains=matrix
)
rownames(dd)-c(a,b)
tt-new(myclass,dd)
#the source of pain.
as(tt,matrix)-matrix(1,3,3)
Error: length of dimnames [1] not equal to array extent
Is there a different way to do what I would like to do (I would like to change the @.Data and all its attributes in the object)?
   

It's not particularly a problem with as().  Your class just doesn't
behave as you expect.
matrix is not a formal class with slots.  (It isn't even an S3 class
in R; attr(x,class) is NULL.)  So you cannot expect classes extending
matrix to know what a matrix is supposed to be.
Part of the problem is that matrix objects sometimes have dimnames and
sometimes don't.  And there is basic code in R that assumes or applies
constraints on the dim or dimnames.
In S-Plus, matrix is a formal class, always having a slot for
dimnames.  R has not gone that route, at least not yet.
It may be possible to define a new class, Matrix, say, that looks like
a matrix to old-style code but has a formal definition.  But the details
are likely to be tricky, and it's definitely a topic for r-devel, not
r-help.
John Chambers
 

Eryk.
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
   

 

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] aov for unbalanced design (PR#7144)

2004-07-29 Thread Thomas Lumley

It is not a bug. It is supposed to be that way. It is even a FAQ.

-thomas

On Thu, 29 Jul 2004 [EMAIL PROTECTED] wrote:

 Full_Name: Tanya Logvinenko
 Version: 1.7.0
 OS: Windows 2000
 Submission from: (NULL) (132.183.156.125)


 For unbalanced design, I ran into problem with ANOVA (aov function). The sum of
 squares for only for the second factor and total are computed correctly, but sum
 of squares for the first factor is computed incorreclty. Changing order of
 factors in the formula changes the ANOVA table. For the balanced design, there
 is no such problem.

  summary(aov(data[1,]~factor1+factor2))
 Df  Sum Sq Mean Sq F valuePr(F)
 factor1  5 1524420  304884  6.4529 0.0003229 ***
 factor2  7 1447830  206833  4.3776 0.0017808 **
 Residuals   31 1464674   47248
 ---
 Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
  summary(aov(data[1,]~factor2+factor1))
 Df  Sum Sq Mean Sq F valuePr(F)
 factor2  7 1648225  235461  4.9836 0.0007295 ***
 factor1  5 1324025  264805  5.6046 0.0008612 ***
 Residuals   31 1464674   47248
 ---
 Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1

 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-devel


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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-devel


[Rd] Re: matrix subsetting (was: [R] as(obj,

2004-07-29 Thread Gabor Grothendieck


Suggest you try R 1.9.1 patched.  This is what I get on 
Windows XP with that:

 matrixObj - array(1:4, c(2,2))
 class(matrixObj) - matrix
 fooObj - matrixObj
 class(fooObj) - foo
 fooObj[1:2]
[1] 1 2
 matrixObj[1:2]
[1] 1 2
 getAnywhere([.matrix)
no object named '[.matrix' was found
 getAnywhere([.foo)
no object named '[.foo' was found
 
 args([.matrix)
Error in args([.matrix) : couldn't find function [.matrix
 body([.matrix)
Error in get(x, envir, mode, inherits) : variable [.matrix of mode function was 
not found
 R.version.string
[1] R version 1.9.1, 2004-07-13







Date:   Thu, 29 Jul 2004 21:46:27 +0100
From:   Patrick Burns [EMAIL PROTECTED]
To: John Chambers [EMAIL PROTECTED], [EMAIL PROTECTED]
Subject:[Rd] Re: matrix subsetting (was: [R] as(obj,matrix))

On a related topic, a client came up with this example
a few days ago which I was unable to explain. (But he
did heed my advise of don't do that.)


 matrixObj - array(1:4, c(2,2))
 class(matrixObj) - matrix
 fooObj - matrixObj
 class(fooObj) - foo
 fooObj[1:2]
Testing
[,1] [,2]
[1,] 1 3
[2,] 2 4
attr(,class)
[1] foo
 matrixObj[1:2]
[1] 1 2
 get([.matrix)
function(x, i, j, drop = if(missing(i)) TRUE else length(cols)==1)
{
cat(Testing\n)
x
}
 get([.foo)
function(x, i, j, drop = if(missing(i)) TRUE else length(cols)==1)
{
cat(Testing\n)
x
}

Everything is the same except for the name of the class. When
the class is matrix, it ignores the subset method. But the very
same code works if the class is foo. This is 1.9.1 Windows,
and the same happens with 1.7.0 (the oldest version I have on
my machine).

What is happening here?


Patrick Burns

Burns Statistics
[EMAIL PROTECTED]
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and A Guide for the Unwilling S User)


John Chambers wrote:

Wolski wrote:


Hi!

Here a simple example.

setClass(myclass
,representation(info=character)
,contains=matrix
)

rownames(dd)-c(a,b)
tt-new(myclass,dd)
#the source of pain.
as(tt,matrix)-matrix(1,3,3)
Error: length of dimnames [1] not equal to array extent

Is there a different way to do what I would like to do (I would like to change the 
@.Data and all its attributes in the object)?



It's not particularly a problem with as(). Your class just doesn't
behave as you expect.

matrix is not a formal class with slots. (It isn't even an S3 class
in R; attr(x,class) is NULL.) So you cannot expect classes extending
matrix to know what a matrix is supposed to be.

Part of the problem is that matrix objects sometimes have dimnames and
sometimes don't. And there is basic code in R that assumes or applies
constraints on the dim or dimnames.

In S-Plus, matrix is a formal class, always having a slot for
dimnames. R has not gone that route, at least not yet.

It may be possible to define a new class, Matrix, say, that looks like
a matrix to old-style code but has a formal definition. But the details
are likely to be tricky, and it's definitely a topic for r-devel, not
r-help.

John Chambers



Eryk.


__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] aov for unbalanced design (PR#7144)

2004-07-29 Thread Prof Brian Ripley
What do you think is the correct answer and on what authority?
(These are explicitly sequential aka Type 1 anova tables.)

That the SSqs depend on the order of fitting is a feature of an unbalanced 
design.  I believe that R is correct and your understanding is not.

On Thu, 29 Jul 2004 [EMAIL PROTECTED] wrote:

 Full_Name: Tanya Logvinenko
 Version: 1.7.0

Oh, please!  Don't send in bug reports from very old versions -- there 
have been 5 releases since then.

 OS: Windows 2000
 Submission from: (NULL) (132.183.156.125)
 
 
 For unbalanced design, I ran into problem with ANOVA (aov function). The sum of
 squares for only for the second factor and total are computed correctly, but sum
 of squares for the first factor is computed incorreclty. Changing order of
 factors in the formula changes the ANOVA table. For the balanced design, there
 is no such problem.
 
  summary(aov(data[1,]~factor1+factor2))
 Df  Sum Sq Mean Sq F valuePr(F)
 factor1  5 1524420  304884  6.4529 0.0003229 ***
 factor2  7 1447830  206833  4.3776 0.0017808 ** 
 Residuals   31 1464674   47248  
 ---
 Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 
  summary(aov(data[1,]~factor2+factor1))
 Df  Sum Sq Mean Sq F valuePr(F)
 factor2  7 1648225  235461  4.9836 0.0007295 ***
 factor1  5 1324025  264805  5.6046 0.0008612 ***
 Residuals   31 1464674   47248  
 ---
 Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1

The FAQ has a section on BUGS asking for a *reproducible* example.  This 
is not.

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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-devel