[R] S4 Methods with large numbers of args using memory

2006-06-06 Thread Joseph Wang
Thanks all to the people on the r-help list for the backtick help.

I've run into another problem.  With my SWIG C++ wrapper for R, I'm finding 
that S4 generic functions with large numbers of argument (such as 10 or 11) 
seem to be taking up a lot of memory especially when a lot of the arguments 
are set to missing.

This happens because I'm generating S4 methods to wrapper C++ functions with 
optional arguments.  Each wrapper can take several meg of heap causing my R 
program to quickly run out of heap memory.

Any ideas as to what the problem is and any possible way of working around it?

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


[R] Functions starting with underscores

2006-06-04 Thread Joseph Wang
I'm having problems with functions starting with underscores

'_foo' - function(x) {1}

seems to work

but I can't assign an attribute to this function

attr('_foo', 'bar') - 'pow'

Any way of doing this?  This is for a C++ - R wrapping system so I'd like to 
keep the C++ names which start with underscores.

(please cc: responses to me personally)

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


[R] type converters not being saved to workspace

2006-04-09 Thread Joseph Wang
Any one can explain why this happens or any work arounds?

 setClass('foo')
[1] foo
 setAs('foo', 'character', function(from) from)
 showMethods('coerce')

Function coerce:
from = ANY, to = array
from = ANY, to = call
from = ANY, to = character
from = ANY, to = complex
from = ANY, to = environment
from = ANY, to = expression
from = ANY, to = function
from = ANY, to = integer
from = ANY, to = list
from = ANY, to = logical
from = ANY, to = matrix
from = ANY, to = name
from = ANY, to = numeric
from = ANY, to = single
from = ANY, to = ts
from = ANY, to = vector
from = ANY, to = NULL
from = foo, to = character
 q()
Save workspace image? [y/n/c]: y


(restart)

 showMethods('coerce')

Function coerce:
from = ANY, to = array
from = ANY, to = call
from = ANY, to = character
from = ANY, to = complex
from = ANY, to = environment
from = ANY, to = expression
from = ANY, to = function
from = ANY, to = integer
from = ANY, to = list
from = ANY, to = logical
from = ANY, to = matrix
from = ANY, to = name
from = ANY, to = numeric
from = ANY, to = single
from = ANY, to = ts
from = ANY, to = vector
from = ANY, to = NULL
from = NULL, to = OptionalFunction


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


[R] setMethod and contains not saving

2006-02-23 Thread Joseph Wang
Sorry if this is a duplicate

I'm having the following problem saving methods which are subclasses of other
objects.  Is there a workaround.  The problem is that the R file that
triggers this bug is several meg, and I'd like to load from a RData file.

This works

 setClass('foo')

[1] foo

 setMethod('$', 'foo', function(x,name) x)

[1] $

 showMethods('$')

Function $:
x = ANY
x = foo

 q()

Save workspace image? [y/n/c]: y
(restart)

 showMethods('$')

Function $:
x = ANY
x = foo

This doesn't 

 setClass('bar', contains='foo')

[1] bar

 setMethod('$', 'bar', function(x,name)x)

[1] $

 showMethods('$')

Function $:
x = ANY
x = foo
x = bar

 q()

Save workspace image? [y/n/c]: y
(restart)

 showMethods('$')

Function $:
x = ANY

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