Re: [Rd] Newbie Rccp module question. "Failed to initialize module pointer"???

2011-03-03 Thread A Zege
Dirk, thanks for your reply. I posted my answer right away and went on
vacation. My post was pending since then. Still cannot post, so I opened
another profile -- maybe this time it gets through.

To answer your questions, I run  R-2.12.1 on 64 bit RedHat Linux on Xeon
machine.
What seems odd that the error message i am getting refers to .GlobalEnv
package. The symbol it is looking for, _rcpp_module_boot_mod, is in shared
library for my package, i checked it with nm. Is there any doc on how
modules are implemented? 

--
View this message in context: 
http://r.789695.n4.nabble.com/Newbie-Rccp-module-question-Failed-to-initialize-module-pointer-tp3311388p3332652.html
Sent from the R devel mailing list archive at Nabble.com.

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


[Rd] super basic questions about S4 classes

2011-04-05 Thread A Zege
Apologies for asking something that is probably super obvious, i just started
with S4 classes and i guess i am not finding documentation that layout the
grammar rules and give enough examples. Some questions i am having are these

1. I understand that main method of writing a member function is to write a
generic function and setMethod for this particular object. This, however,
presumes that there is "virtuality" for this function, i.e. it could be used
with other inherited classes . Truth is, many, if not most of my functions
don't have virtuality in mind. I want to write them inside classes to
achieve incapsulaton only -- use class member data without passing it as
parameters or making global to a bunch of functions and have some specific
class member functions that don't pollute a global namespace and can be
called only for a particular class. This is what i know how to do with
enclosures in R. Is there some obvious way of setting this environment local
to a class without writing generic functions that i am missing?

2. Is it possible to overload functions in other ways than having default
parameter values and prototypes?
For example, can i have  two constructors with completely different sets of
parameters?

3. Is there some good way to debug S4 classes? I am very fond of mtrace()
from debug package, but the simple set of commands i normally use doesn't
take me into class methods. 


Would appreciate any pointers on these..


--
View this message in context: 
http://r.789695.n4.nabble.com/super-basic-questions-about-S4-classes-tp3428591p3428591.html
Sent from the R devel mailing list archive at Nabble.com.

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


[Rd] S4 generic functions/methods vs enclosures

2011-04-06 Thread A Zege
Apologies for asking something that is probably very obvious, i just started
with S4 classes and i guess i am not finding documentation that lays out the
grammar rules and gives enough examples. 

I understand that main method of writing a member function is to write a
generic function and setMethod for this particular class. This, however,
presumes that there is "virtuality" for this function, i.e. it could be used
with other inherited classes . Truth is, many, if not most of my functions
don't have virtuality in mind. I want to write them inside classes to
achieve incapsulaton only -- use class member data without passing it as
parameters or making global to a bunch of functions and have some specific
class member functions that don't pollute a global namespace and can be
called only for a particular class. This is what enclosured do in R. Is
there some obvious way of setting this environment local to a class and 
without writing generic functions that i am missing?


Would appreciate any pointers 


--
View this message in context: 
http://r.789695.n4.nabble.com/S4-generic-functions-methods-vs-enclosures-tp3430950p3430950.html
Sent from the R devel mailing list archive at Nabble.com.

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


Re: [Rd] S4 generic functions/methods vs enclosures

2011-04-06 Thread A Zege
This looks awesome -- it is precisely what i wanted. I have started hacking
with passing around environments  to simulate behavior of classes i was
after, but this is so much neater. Reference classes seem to do precisely
what i wanted. Thank you very much.

--
View this message in context: 
http://r.789695.n4.nabble.com/S4-generic-functions-methods-vs-enclosures-tp3430950p3431755.html
Sent from the R devel mailing list archive at Nabble.com.

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


[Rd] How to debug reference classes?

2011-04-07 Thread A Zege
How do you debug methods of a reference class? I've been using mtrace, which
is excellent, but i cannot figure out how to mtrace a reference class
method. Maybe there is some other way to debug these, for example with
ordinary trace? for now i am only able to use options(error=recover), which
is not giving me idea where exactly in the code i am once i am stopped on an
error. 

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-debug-reference-classes-tp3434269p3434269.html
Sent from the R devel mailing list archive at Nabble.com.

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


Re: [Rd] How to debug reference classes?

2011-04-08 Thread A Zege
Thank you very much, gentlemen. It seems reference classes will make my life
much easier. I won't pretend that i fully understand the wizardry with
environments that you do, but it works :). Namely the steps to mtrace a
class method by doing what John and Mark outlined
   xx$edit<-xx$edit
   mtrace(edit, from=xx)
   xx$edit(1,1,99)

do the magic of starting mtrace which solves my problem for practical
purposes. I was not able to make the second part of prescription related to
debugging unconstructed objects work. Namely, whenever i do 

 mtrace( edit, from=mEditor$def@refMethods) 

I get 
Error in parent.env(from) : the empty environment has no parent. Must be
doing something wrong, but haven't yet figured what.

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-debug-reference-classes-tp3434269p3436674.html
Sent from the R devel mailing list archive at Nabble.com.

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


[Rd] problem subsetting of a reference class

2011-04-21 Thread A Zege
I am trying to define subset operator for a reference class and hitting some
problem i am unable to diagnose.To give an example, here is a toy class
generator that is a wrapper around a list




tmpGEN<-setRefClass("TMP", fields=list(
namelist="list"
))
tmpGEN$methods('add'=function(obj, name){
namelist[[name]]<<-obj
})

tmpGEN$methods('['=function(name){
if(class(name)!="character")
stop('to return cache element need to pass its 
name')
ind<-match(name, names(namelist))
if(is.na(ind))
stop('data to remove is not in namelist')
namelist[[name]]
})


==

when i try to use it, the following happens
v<-rnorm(10)
tmp<-tmpGEN$new()
tmp$add(v, 'random')

. up until here everything is ok, class is generated and vector is
added. Now when i do
tmp['random']

i get error message 

Error in tmp["random"] : object of type 'S4' is not subsettable

Not sure if it means that i cannot define "[" operator for a class or if i
am doing it syntactically wrong


--
View this message in context: 
http://r.789695.n4.nabble.com/problem-subsetting-of-a-reference-class-tp3466690p3466690.html
Sent from the R devel mailing list archive at Nabble.com.

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


[Rd] how to make a true binary package?

2011-10-11 Thread A Zege

I'd like to have a version of a package that doesn't include sources. I
thought that this could be achieved by using binary option in R CMD build,
but in fact it packages source code that could be easily printed once the
library is loaded. Is there an option to avoid visibility of the source? 

Another related question is how to install two versions of the same package,
so that i could load either of them? I am sure this could be done, just
cannot find this in docs.

I am using R 2.12.1 on Red Hat Lunix 

--
View this message in context: 
http://r.789695.n4.nabble.com/how-to-make-a-true-binary-package-tp3895117p3895117.html
Sent from the R devel mailing list archive at Nabble.com.

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


Re: [Rd] how to make a true binary package?

2011-10-11 Thread A Zege
OK, gentlemen, i agree with you in general. I was not talking about a general
purpose, general use package that one prepares for CRAN. I am sure you are
familiar professionally or can imagine situations where you need to
demonstrate a solution to a specific task without fully disclosing the
details -- sometimes even hard core open source adherents need to sacrifice
desire for openness for some prosaic purposes, like getting paid :).
Compilable languages give an easy solution of a binary code. It sounds like
if one wants true binary, he has to recode in C++. I thought it's possible
in R as well, i thought this was discussed even as a default behavior for
next version of R to make stuff go faster. Maybe not. Thanks, anyway.


--
View this message in context: 
http://r.789695.n4.nabble.com/how-to-make-a-true-binary-package-tp3895117p3895262.html
Sent from the R devel mailing list archive at Nabble.com.

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