[Rd] substitute and S4 objects

2007-03-24 Thread Franck Arnaud
Hi all,
I don't understand why this does not what I expect :

## code start here ##
setClass("num",representation(x="numeric"))

num<-function(x) new("num",x=x)

add<-function(e1,e2) {
cat("Computing
",deparse(substitute(e1)),"+",deparse(substitute(e2)),"\n")
[EMAIL PROTECTED]@x
}

setMethod("+","num",function(e1,e2) {
cat("Computing
",deparse(substitute(e1)),"+",deparse(substitute(e2)),"\n")
[EMAIL PROTECTED]@x
})


a<-num(3.2)
b<-num(-1.4)

add(a,b)
a+b
## code ends here ##

a+b does not work : I would like that add(a,b) and a+b give the exact same
result
I've seen a post on R-devel, but the answer seemed not to apply here.
I've tried to use deparse(substitute(e1,sys.frame (-1))) and
deparse(substitute(e1,sys.frame(-2))) (as it was advised by GG in january
2006). But it did not work.

Therefore, i'm looking for 1) an explanation for this phenomenon (link to a
doc, anything) and/or 2) a way to do what i want, if it is possible.

Thanks a lot

[[alternative HTML version deleted]]

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


[Rd] Calloc : syntax error

2006-04-13 Thread Franck Arnaud
Hi,
I have issue with Calloc : at the compilation step, gcc tells "error :
syntax error before ')' token".
When I use the classical C calloc... free, everything's fine.
Here's the part of code :
a = (double*) Calloc(*n,sizeof(double));

when i remove this line or replace it with the calloc, it's ok

Hint : In the header file R.h, there's a line :
/* for PROBLEM ... Calloc, Realloc, Free, Memcpy, F77_ */
is it related ?

Does anyone know ?
Thanks

[[alternative HTML version deleted]]

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


[Rd] S3 fonctions for object of S4 class

2006-08-23 Thread Franck Arnaud
Hello !
there's a S3 method called start (and end too) to be used with objects of
class ts (package stats). I am writing a S4 class for which I would like to
use this function start, so that start with a ts calls the former method and
start with my S4 class (called MA) calls the function I want.
For the 'plot' command I do :
setGeneric("plot",function(x,y,...) standardGeneric("plot"))
and
setMethod("plot",signature(x="MA",y="ANY"),function(x,y,...)
plotMA(x,y,...))
and it works just fine.

When I try this with start, I does not work at all : the old function and
the new do not work. I get an error during the check and when I execute
commands, the error is like evaluations are too deeply nested (I'm not sure
of the translation).

I've tried to look for information (in mailing lists, WRE, Rlang,...), but
i'm kinda lost... Any help appreciated !

Thanks

[[alternative HTML version deleted]]

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


[Rd] Using substitute from inside an S4 method

2006-12-13 Thread Franck Arnaud
Hi all,
I don't understand why this does not what I expect :

## code start here ##
setClass("num",representation(x="numeric"))

num<-function(x) new("num",x=x)

add<-function(e1,e2) {
cat("Computing
",deparse(substitute(e1)),"+",deparse(substitute(e2)),"\n")
[EMAIL PROTECTED]@x
}

setMethod("+","num",function(e1,e2) {
cat("Computing
",deparse(substitute(e1)),"+",deparse(substitute(e2)),"\n")
[EMAIL PROTECTED]@x
})


a<-num(3.2)
b<-num(-1.4)

add(a,b)
a+b
## code ends here ##

a+b does not work : I would like that add(a,b) and a+b give the exact same
result
I've seen a post on R-devel, but the answer seemed not to apply here.
I've tried to use deparse(substitute(e1,sys.frame(-1))) and
deparse(substitute(e1,sys.frame(-2))) (as it was advised by GG in january
2006). But it did not work.

Therefore, i'm looking for 1) an explanation for this phenomenon (link to a
doc, anything) and/or 2) a way to do what i want, if it is possible.

Thanks a lot

[[alternative HTML version deleted]]

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