Thanks to all replies.
I was able to get it running with the R.oo package.
I hope this reply makes it to the proper thread.
Michael
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo
Thanks for the correction. Personally, I never really use that kind of
assignments, and the deparse(substitute()) construct I only use in
self-defined plotting functions in simple scripts to be run on series
of equivalent datasets by me, myself and I.
When writing a package with nested functions a
I think you should be interested by section 5.4 (non-local assignments;
closures) in Chamber's "Software for Data Analysis" book published in
2008 by Springer
(http://www.springer.com/statistics/computanional+statistics/book/978-0-387-75935-7).
Besides the solution proposed in the book, which
Pass an object of, or containing an, environment. Then whenever you
modify any object "inside" the environment, the changes will remain
also when exiting from the function(s). This has been used by many
for quite some time and is the standard way to do it, if you need this
feature. See packages
In case you want the function setData to change the object itself
(which is often a dangerous idea!), you can use instead :
setMethod("setData","test",
function(this,fcn,k){
Name <- deparse(substitute(this))
t...@t <- as.numeric(seq(-k,k))/(2*k+1)
t...@f <- sapply(t...@t,FUN=fcn)
by returning the object ?
setMethod("setData","test",
function(this,fcn,k){
t...@t <- as.numeric(seq(-k,k))/(2*k+1)
t...@f <- sapply(t...@t,FUN=fcn) #changed!
return(this) #changed!
}
)
#
Greetings,
I love the R system and am sincerely grateful for the great effort the
product and contributors
are delivering.
My question is as follows:
I am trying to use S4 style classes but cannot write functions that modify
an object
because paramter passing is by value.
For example I want to d
7 matches
Mail list logo