Re: [Rd] Vignette Questions

2010-11-17 Thread friedrich . leisch
> Dear List,
>
> I recently stumbled over the possibility and need to specifiy
> % \VignetteDepends{}
> in my vignettes. I did not know about this, and I notice that it is not
> mentioned in the R-extensions manual section "Writing package vignettes".
> [...]

Very strange, both Kurt Hornik and myself could have sworn that this has
been documented. But of course you are right that it currently is not and
clearly should be. I will have a shot later this week.

Best regards,
Fritz Leisch

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


Re: [Rd] R5 reference classes: how to initialize exactly?

2010-11-17 Thread Simon Urbanek
Just a clarification for posterity - R5 has nothing to do with the new 
reference classes. It's not even an official name, but informally it's a 
collection of ideas for an entirely new object system that can replace both S3 
and S4 (not that it will but it should be seen as having the capability to do 
so technically). Reference classes are just an addition to S4.

Cheers,
Simon


On Nov 16, 2010, at 12:30 AM, Janko Thyson wrote:

> Sorry, I was stupid:
> 
> 
> 
> MyRefObj <- setRefClass("Blabla", .)
> 
> 
> 
> One can always get the generator object of an defined class with
> 'getRefClass()'. So:
> 
> 
> 
> g <- getRefClass("Blabla")
> 
> x <- g$new(.)
> 
> 
> 
> Regards,
> 
> Janko
> 
> 
> 
> 
> 
> Von: Janko Thyson [mailto:janko.thy...@ku-eichstaett.de] 
> Gesendet: Dienstag, 16. November 2010 00:27
> An: 'r-de...@r-project. org'
> Betreff: R5 reference classes: how to initialize exactly?
> 
> 
> 
> Dear List,
> 
> 
> 
> So far, I really like those new R5 classes. But what kind of puzzles me is
> that it's not just enough to define the actual reference class, I also have
> to assign it to an object (e.g. 'MyRefObj') in order to fire
> 'MyRefObj$new(.)'.
> 
> 
> 
> S4:
> 
> setClass("Blabla", .)
> 
> x <- new("Blabla")
> 
> 
> 
> R5:
> 
> MyRefObj <- setRefClass("Blabla", .)
> 
> x <- MyRefObj$new(.)
> 
> 
> 
> But then how do I define a reference class in a package that should be
> available after the package is loaded via 'library(my_pkg)' as there is no
> 'MyRefObj' at startup yet? Do I have to call the script where the definition
> lives?
> 
> 
> 
> Thanks for any comments,
> 
> Janko
> 
> 
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> 

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


Re: [Rd] R5 reference classes: how to initialize exactly?

2010-11-17 Thread Janko Thyson
> -Ursprüngliche Nachricht-
> Von: Simon Urbanek [mailto:simon.urba...@r-project.org]
> Gesendet: Mittwoch, 17. November 2010 11:35
> An: Janko Thyson
> Cc: 'r-de...@r-project. org'
> Betreff: Re: [Rd] R5 reference classes: how to initialize exactly?
> 
> Just a clarification for posterity - R5 has nothing to do with the new
> reference classes. It's not even an official name, but informally it's a
> collection of ideas for an entirely new object system that can replace
> both S3 and S4 (not that it will but it should be seen as having the
> capability to do so technically). Reference classes are just an addition
> to S4.
> 
> Cheers,
> Simon

Thanks for that clarification. I picked that name up from the Google
TechTalks presentation of Dirk and Romain. So I refer to them as S4
reference classes in future posts?

Regards,
Janko

> 
> 
> On Nov 16, 2010, at 12:30 AM, Janko Thyson wrote:
> 
> > Sorry, I was stupid:
> >
> >
> >
> > MyRefObj <- setRefClass("Blabla", .)
> >
> >
> >
> > One can always get the generator object of an defined class with
> > 'getRefClass()'. So:
> >
> >
> >
> > g <- getRefClass("Blabla")
> >
> > x <- g$new(.)
> >
> >
> >
> > Regards,
> >
> > Janko
> >
> >
> >
> >
> >
> > Von: Janko Thyson [mailto:janko.thy...@ku-eichstaett.de]
> > Gesendet: Dienstag, 16. November 2010 00:27
> > An: 'r-de...@r-project. org'
> > Betreff: R5 reference classes: how to initialize exactly?
> >
> >
> >
> > Dear List,
> >
> >
> >
> > So far, I really like those new R5 classes. But what kind of puzzles
> me is
> > that it's not just enough to define the actual reference class, I also
> have
> > to assign it to an object (e.g. 'MyRefObj') in order to fire
> > 'MyRefObj$new(.)'.
> >
> >
> >
> > S4:
> >
> > setClass("Blabla", .)
> >
> > x <- new("Blabla")
> >
> >
> >
> > R5:
> >
> > MyRefObj <- setRefClass("Blabla", .)
> >
> > x <- MyRefObj$new(.)
> >
> >
> >
> > But then how do I define a reference class in a package that should be
> > available after the package is loaded via 'library(my_pkg)' as there
> is no
> > 'MyRefObj' at startup yet? Do I have to call the script where the
> definition
> > lives?
> >
> >
> >
> > Thanks for any comments,
> >
> > Janko
> >
> >
> >
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-devel@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
> >

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


Re: [Rd] R5 reference classes: how to initialize exactly?

2010-11-17 Thread Romain Francois

Le 17/11/10 11:39, Janko Thyson a écrit :



-Ursprüngliche Nachricht-
Von: Simon Urbanek [mailto:simon.urba...@r-project.org]
Gesendet: Mittwoch, 17. November 2010 11:35
An: Janko Thyson
Cc: 'r-de...@r-project. org'
Betreff: Re: [Rd] R5 reference classes: how to initialize exactly?

Just a clarification for posterity - R5 has nothing to do with the new
reference classes. It's not even an official name, but informally it's a
collection of ideas for an entirely new object system that can replace
both S3 and S4 (not that it will but it should be seen as having the
capability to do so technically). Reference classes are just an addition
to S4.

Cheers,
Simon


Thanks for that clarification. I picked that name up from the Google
TechTalks presentation of Dirk and Romain. So I refer to them as S4
reference classes in future posts?

Regards,
Janko


Sorry about that. It was meant as a sort of private joke. (we do say in 
the talk that this is not an official name).



On Nov 16, 2010, at 12:30 AM, Janko Thyson wrote:


Sorry, I was stupid:



MyRefObj<- setRefClass("Blabla", .)



One can always get the generator object of an defined class with
'getRefClass()'. So:



g<- getRefClass("Blabla")

x<- g$new(.)



Regards,

Janko





Von: Janko Thyson [mailto:janko.thy...@ku-eichstaett.de]
Gesendet: Dienstag, 16. November 2010 00:27
An: 'r-de...@r-project. org'
Betreff: R5 reference classes: how to initialize exactly?



Dear List,



So far, I really like those new R5 classes. But what kind of puzzles

me is

that it's not just enough to define the actual reference class, I also

have

to assign it to an object (e.g. 'MyRefObj') in order to fire
'MyRefObj$new(.)'.



S4:

setClass("Blabla", .)

x<- new("Blabla")



R5:

MyRefObj<- setRefClass("Blabla", .)

x<- MyRefObj$new(.)



But then how do I define a reference class in a package that should be
available after the package is loaded via 'library(my_pkg)' as there

is no

'MyRefObj' at startup yet? Do I have to call the script where the

definition

lives?



Thanks for any comments,

Janko



--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/9VOd3l : ZAT! 2010
|- http://bit.ly/c6DzuX : Impressionnism with R
`- http://bit.ly/czHPM7 : Rcpp Google tech talk on youtube

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


[Rd] Reference classes: accessor functions via 'getRefClass(...)$accessors(...)'

2010-11-17 Thread Janko Thyson
Hi there,

 

I'd like to choose between an "static" and "dynamic" access of a reference
class field, say 'a'.

 

myObj <- getRefClass("Blabla")$new()

 

Static:   myObj$a

Dynamic: myObj$a.get() where the function retrieves the data
from a database (or some other location), stores it to a buffer and
optionally updates the static field value 'a'.

 

I've set up such a method 'a.get()' where I can actually decide between
static and dynamic runmode (so the method also wraps the call 'myObj$a' for
the static runmode).

 

Now I saw that setting up such accessor methods (get/set) is already done
for me if I use 'getRefClass("Blabla")$accessors(.)'. I just don't
understand what exactly I have to do there, because this results in an
error: 'getRefClass("Blabla")$accessors("a")'

 

Can anyone point me to the correct use of 'getRefClass(.)$accessors(.)'?

 

Thanks a lot,

Janko


[[alternative HTML version deleted]]

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


Re: [Rd] Reference classes: accessor functions via 'getRefClass(...)$accessors(...)'

2010-11-17 Thread Romain Francois

Le 17/11/10 13:07, Janko Thyson a écrit :


Hi there,



I'd like to choose between an "static" and "dynamic" access of a reference
class field, say 'a'.



myObj<- getRefClass("Blabla")$new()



Static:   myObj$a

Dynamic: myObj$a.get() where the function retrieves the data
from a database (or some other location), stores it to a buffer and
optionally updates the static field value 'a'.



I've set up such a method 'a.get()' where I can actually decide between
static and dynamic runmode (so the method also wraps the call 'myObj$a' for
the static runmode).



Now I saw that setting up such accessor methods (get/set) is already done
for me if I use 'getRefClass("Blabla")$accessors(.)'. I just don't
understand what exactly I have to do there, because this results in an
error: 'getRefClass("Blabla")$accessors("a")'



Can anyone point me to the correct use of 'getRefClass(.)$accessors(.)'?



Thanks a lot,

Janko


Hi,

fields can either be data or active binding functionss. See 
?makeActiveBinding for some example of active binding functions in their 
original context.


Here is an example of a reference class that keeps its data in a file.

require( methods )

Foo <- setRefClass( "Foo",
fields = list(
file = "character",
x = function(value){
if( missing( value ) ){
read.table( file )
} else{
write.table( value, file = file )
}
}
)
)

foo <- Foo$new( file="/tmp/iris.txt" )
foo$x <- iris
foo$x

write.table( subset( iris, Petal.Length < 2), file = "/tmp/iris.txt" )
foo$x


Does that help ?


Romain

--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/9VOd3l : ZAT! 2010
|- http://bit.ly/c6DzuX : Impressionnism with R
`- http://bit.ly/czHPM7 : Rcpp Google tech talk on youtube

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


[Rd] Subclasses of class "call" not possible in R.

2010-11-17 Thread Vitalie S.

Hello Everyone!

I am trying to extend the class "call", but keep getting errors whatever I do:

setClass("mycall", contains = "call")
#[1] "mycall"

new("mycall")
#Error in function (object)  : 
#  error in evaluating the argument 'object' in selecting a method for function
#'show'

new("mycall", quote(a+b))
#Error in .getClassFromCache(Class, where) : 
#  could not find function ""


I understand this is rarely needed, but for some special reasons I really need
the class "call" (as usually returned by quote and substitute) and not class
"expression".

Would really appreciate any workarounds.

Thanks,
Vitalie.

platform   i386-pc-mingw32 
arch   i386
os mingw32 
system i386, mingw32   
status Patched 
major  2   
minor  12.0
year   2010
month  11  
day01  
svn rev53513   
language   R   
version.string R version 2.12.0 Patched (2010-11-01 r53513)

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


Re: [Rd] Reference classes: accessor functions via 'getRefClass(...)$accessors(...)'

2010-11-17 Thread Vitalie S.
"Janko Thyson"  writes:

> Hi there,
>
> I'd like to choose between an "static" and "dynamic" access of a reference
> class field, say 'a'.
>
> myObj <- getRefClass("Blabla")$new()
>
> Static:   myObj$a
>
> Dynamic: myObj$a.get() where the function retrieves the data
> from a database (or some other location), stores it to a buffer and
> optionally updates the static field value 'a'.
>
> I've set up such a method 'a.get()' where I can actually decide between
> static and dynamic runmode (so the method also wraps the call 'myObj$a' for
> the static runmode).
>
> Now I saw that setting up such accessor methods (get/set) is already done
> for me if I use 'getRefClass("Blabla")$accessors(.)'. I just don't
> understand what exactly I have to do there, because this results in an
> error: 'getRefClass("Blabla")$accessors("a")'
>
> Can anyone point me to the correct use of 'getRefClass(.)$accessors(.)'?

It works for me:

X <- setRefClass("XXX", fields = list(a = "character"))
X$accessors("a")
X
# ...
# Class Methods:  
#"callSuper", "export", "getA", "import", "initFields", "setA"
# ...

accessors() convenience method creates setA and getA functions:

x <- X$new()
x$getA
#Class method definition for method getA()
#function () 
#a
#

HTH,
Vitalie.

> 
>
> Thanks a lot,
>
> Janko
>
>   [[alternative HTML version deleted]]

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


Re: [Rd] [R] DBLEPR?

2010-11-17 Thread Prof. John C Nash
Thanks for comments from several folk, fix from Doug Bates and start to finding 
new email
for ucminf maintainer.

Summary of responses:

DBLEPR and its relations are briefly mentioned but with no or minimal examples 
in Writing
R Extensions as well as Venables and Ripley book. I should have emphasized I was
especially seeking examples, and Brian Ripley has pointed out that cluster, mda 
and
tweedie among others use these routines.

Fortran WRITE or PRINT routines, even if unused by code, may interfere with C 
output,
especially in Windows. (See R-devel post from Brian Ripley).

Doug Bates provided a different approach and code that appears to fix ucminf.

We have a lead on contacting the maintainer, who has moved, so hopefully the 
package can
be updated.

My conclusion from this: xxxPR routines are still usable, but likely not the 
best approach
for output from Fortran routines.

Once again, thanks to all.

JN

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


Re: [Rd] Reference classes: accessor functions via 'getRefClass(...)$accessors(...)'

2010-11-17 Thread Janko Thyson
Thanks a lot for the comments! I'll give the serveral alternatives a try to
see if it gets me what I want.

Cheers, 
Janko

> -Ursprüngliche Nachricht-
> Von: Vitalie S. [mailto:spinuvit.l...@gmail.com]
> Gesendet: Mittwoch, 17. November 2010 13:51
> An: Janko Thyson
> Cc: 'r-de...@r-project. org'
> Betreff: Re: Reference classes: accessor functions via
> 'getRefClass(...)$accessors(...)'
> 
> "Janko Thyson"  writes:
> 
> > Hi there,
> >
> > I'd like to choose between an "static" and "dynamic" access of a
> reference
> > class field, say 'a'.
> >
> > myObj <- getRefClass("Blabla")$new()
> >
> > Static:   myObj$a
> >
> > Dynamic: myObj$a.get() where the function retrieves the
> data
> > from a database (or some other location), stores it to a buffer and
> > optionally updates the static field value 'a'.
> >
> > I've set up such a method 'a.get()' where I can actually decide
> between
> > static and dynamic runmode (so the method also wraps the call
> 'myObj$a' for
> > the static runmode).
> >
> > Now I saw that setting up such accessor methods (get/set) is already
> done
> > for me if I use 'getRefClass("Blabla")$accessors(.)'. I just don't
> > understand what exactly I have to do there, because this results in
> an
> > error: 'getRefClass("Blabla")$accessors("a")'
> >
> > Can anyone point me to the correct use of
> 'getRefClass(.)$accessors(.)'?
> 
> It works for me:
> 
> X <- setRefClass("XXX", fields = list(a = "character"))
> X$accessors("a")
> X
> # ...
> # Class Methods:
> #"callSuper", "export", "getA", "import", "initFields", "setA"
> # ...
> 
> accessors() convenience method creates setA and getA functions:
> 
> x <- X$new()
> x$getA
> #Class method definition for method getA()
> #function ()
> #a
> #
> 
> HTH,
> Vitalie.
> 
> >
> >
> > Thanks a lot,
> >
> > Janko
> >
> > [[alternative HTML version deleted]]

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


[Rd] Bug in agrep computing edit distance?

2010-11-17 Thread Dickison, Daniel
I posted this yesterday to r-help and Ben Bolker suggested reposting it
here...

Dickison, Daniel  carnegielearning.com> writes:

>
> The documentation for agrep says it uses the Levenshtein edit distance,
> but it seems to get this wrong in certain cases when there is a
> combination of deletions and substitutions.  For example:
>
> > agrep("abcd", "abcxyz", max.distance=1)
> [1] 1
>
> That should've been a no-match.  The edit distance between those strings
> is 3 (1 substitution, 2 deletions), but agrep matches with max.distance
>>=
> 1.
>
> I didn't find anything in the bug database, so I was wondering if somehow
> I'm misinterpreting how agrep works.  If not, should I file this in
> Bugzilla?
>

  Could you re-post this on r-devel?  It definitely sounds like
this is worth following up.  Based on a little bit of playing around,
it's quite clear that I don't understand what's going on.  The examples
show things like

agrep("lasy","lazy",max=list(sub=0))

 which makes sense, but

agrep("lasy","lazybc",max=1)
agrep("lasy","lazybc",max=0.001)
agrep("lasy","layt",max=list(all=1))

and

agrep("x",c("x","xy","xyz","xyza"),max=list(insertions=2))
agrep("x",c("x","xy","xyz","xyza"),max=list(deletions=2))
agrep("x",c("x","xy","xyz","xyza"),max=list(all=2))

  all give "1 2 3 4" ??

  this makes it clear that I really don't understand what's going on
based on the documentation.  I tried to trace into the C code
(which calls functions from the TRE regexp library) but that didn't
help much ...



Daniel  Dickison
Research Programmer
ddicki...@carnegielearning.com
Toll Free: (888) 851-7094 x103
FAX: (412) 690-2444

Revolutionary Math Curricula. Revolutionary Results.

Carnegie Learning, Inc. | 437 Grant St. 20th Floor | Pittsburgh, PA 15219
www.carnegielearning.com

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


Re: [Rd] Bug in agrep computing edit distance?

2010-11-17 Thread Joris Meys
It might have to do something with spaces and the interpretation of
insertions, as far as I understand the following examples :

> agrep("x",c("x","xy","xyz","xyza"),max=list(all=1))
[1] 1 2 3 4
> agrep("x",c("x","xy  ","xyz ","xyza"),max=list(all=1))
[1] 1
> agrep("xx",c("xx","xyx","xyzx","xyzax",max=list(all=1)))
[1] 1 2 3 4
> agrep("xx",c("xx","xyx","xyzx","xyzax",max=list(ins=1)))
[1] 1 2 3 4
> agrep("xx   ",c("xx   ","xyx  ","xyzx ","xyzax",max=list(all=2)))
[1] 1
> agrep("xx   ",c("xx   ","xyx  ","xyzx ","xyzax",max=list(all=3)))
[1] 1

If the sequences are made the same length in spaces, this function
gives the expected result in the second example, but it definitely
doesn't do that any more when you start playing around with
insertions. If not a bug, it definitely behaves pretty weird...

Cheers
Joris

On Wed, Nov 17, 2010 at 4:49 PM, Dickison, Daniel
 wrote:
> I posted this yesterday to r-help and Ben Bolker suggested reposting it
> here...
>
> Dickison, Daniel  carnegielearning.com> writes:
>
>>
>> The documentation for agrep says it uses the Levenshtein edit distance,
>> but it seems to get this wrong in certain cases when there is a
>> combination of deletions and substitutions.  For example:
>>
>> > agrep("abcd", "abcxyz", max.distance=1)
>> [1] 1
>>
>> That should've been a no-match.  The edit distance between those strings
>> is 3 (1 substitution, 2 deletions), but agrep matches with max.distance
>>>=
>> 1.
>>
>> I didn't find anything in the bug database, so I was wondering if somehow
>> I'm misinterpreting how agrep works.  If not, should I file this in
>> Bugzilla?
>>
>
>  Could you re-post this on r-devel?  It definitely sounds like
> this is worth following up.  Based on a little bit of playing around,
> it's quite clear that I don't understand what's going on.  The examples
> show things like
>
> agrep("lasy","lazy",max=list(sub=0))
>
>  which makes sense, but
>
> agrep("lasy","lazybc",max=1)
> agrep("lasy","lazybc",max=0.001)
> agrep("lasy","layt",max=list(all=1))
>
> and
>
> agrep("x",c("x","xy","xyz","xyza"),max=list(insertions=2))
> agrep("x",c("x","xy","xyz","xyza"),max=list(deletions=2))
> agrep("x",c("x","xy","xyz","xyza"),max=list(all=2))
>
>  all give "1 2 3 4" ??
>
>  this makes it clear that I really don't understand what's going on
> based on the documentation.  I tried to trace into the C code
> (which calls functions from the TRE regexp library) but that didn't
> help much ...
>
>
>
> Daniel  Dickison
> Research Programmer
> ddicki...@carnegielearning.com
> Toll Free: (888) 851-7094 x103
> FAX: (412) 690-2444
>
> Revolutionary Math Curricula. Revolutionary Results.
>
> Carnegie Learning, Inc. | 437 Grant St. 20th Floor | Pittsburgh, PA 15219
> www.carnegielearning.com
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



-- 
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

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


[Rd] Compiling R 2.12.0 from source: error (temp dir)

2010-11-17 Thread Janko Thyson
Dear list,

 

I've just tried to compile R 2.12.0 from source as I think I found an error
in a C function that I would like to fix and check before I go ahead with
posting the presumed error.

 

I've got the R Toolset 2.12 installed and configured correctly and followed
the Admin manual closely (including the entire bitmap stuff; exact same
versions as in the manual). Also, all anti virus software is turned off (as
it complained on some .exe). I have Admin rights on my box.

 

When I run 'make all recommended' I get the following error after a while:

 

cannot create /tmp/R5436: directory nonexistent

mv: cannot stat `/tmp/R5436': No such file or directory

make[3]: *** [mkR] Error 1

make[2]: *** [all] Error 2

make[1]: *** [R] Error 1

make: *** [all] Error 2

 

Any ideas what this is about? Seems that the compiler can't create a temp
directory because of a missing directory. 

 

Thanks for any hints,

Janko


[[alternative HTML version deleted]]

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


Re: [Rd] R5 reference classes: how to initialize exactly?

2010-11-17 Thread John Chambers
On the subject of clarification, Reference Classes are not really an 
"addition" to S4.  They are a programming interface to allow OOP (i.e., 
C++ or Java-style) programming in R.


They do use some S4 tools but rely more on some valuable existing 
techniques for dealing with environments, such as active bindings.  They 
use a thin layer on top of existing R with the goal of simpler and 
clearer programming where object references and class-based methods are 
useful.


John

On 11/17/10 2:34 AM, Simon Urbanek wrote:

Just a clarification for posterity - R5 has nothing to do with the new 
reference classes. It's not even an official name, but informally it's a 
collection of ideas for an entirely new object system that can replace both S3 
and S4 (not that it will but it should be seen as having the capability to do 
so technically). Reference classes are just an addition to S4.




Cheers,
Simon


On Nov 16, 2010, at 12:30 AM, Janko Thyson wrote:


Sorry, I was stupid:



MyRefObj<- setRefClass("Blabla", .)



One can always get the generator object of an defined class with
'getRefClass()'. So:



g<- getRefClass("Blabla")

x<- g$new(.)



Regards,

Janko





Von: Janko Thyson [mailto:janko.thy...@ku-eichstaett.de]
Gesendet: Dienstag, 16. November 2010 00:27
An: 'r-de...@r-project. org'
Betreff: R5 reference classes: how to initialize exactly?



Dear List,



So far, I really like those new R5 classes. But what kind of puzzles me is
that it's not just enough to define the actual reference class, I also have
to assign it to an object (e.g. 'MyRefObj') in order to fire
'MyRefObj$new(.)'.



S4:

setClass("Blabla", .)

x<- new("Blabla")



R5:

MyRefObj<- setRefClass("Blabla", .)

x<- MyRefObj$new(.)



But then how do I define a reference class in a package that should be
available after the package is loaded via 'library(my_pkg)' as there is no
'MyRefObj' at startup yet? Do I have to call the script where the definition
lives?



Thanks for any comments,

Janko




[[alternative HTML version deleted]]

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




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



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


Re: [Rd] Compiling R 2.12.0 from source: error (temp dir)

2010-11-17 Thread Prof Brian Ripley
Is this on Windows?  (Please do consult the posting guide and tell us 
the 'at a minimum' information we asked for.)


If so, it seems you forget the bit about setting TMPDIR right at the 
top of the section on 'Building the core files':


  Set the environment variable @env{TMPDIR} to point to a writable
  directory, with a path specified with forward slashes and no spaces.
  (The default is @file{/tmp}, which may not be useful on Windows.)


On Wed, 17 Nov 2010, Janko Thyson wrote:


Dear list,



I've just tried to compile R 2.12.0 from source as I think I found an error
in a C function that I would like to fix and check before I go ahead with
posting the presumed error.



I've got the R Toolset 2.12 installed and configured correctly and followed
the Admin manual closely (including the entire bitmap stuff; exact same
versions as in the manual). Also, all anti virus software is turned off (as
it complained on some .exe). I have Admin rights on my box.



When I run 'make all recommended' I get the following error after a while:



cannot create /tmp/R5436: directory nonexistent

mv: cannot stat `/tmp/R5436': No such file or directory

make[3]: *** [mkR] Error 1

make[2]: *** [all] Error 2

make[1]: *** [R] Error 1

make: *** [all] Error 2



Any ideas what this is about? Seems that the compiler can't create a temp
directory because of a missing directory.



Thanks for any hints,

Janko


[[alternative HTML version deleted]]

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



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
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

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


[Rd] Reference classes: opinion on OOP design

2010-11-17 Thread Janko Thyson
Dear list,

I'm aware that this post does not really comply with the posting guide with
respect to "providing a minimal reproducible code example". But I do hope
it's okay that I spared uninterested readers by putting that into the
attachment ;-)

The thing is that I'm not really familiar with "true" OOP as R is my first
programming language. So I wanted to ask kindly for some expert opinion on a
certain paradigm I've come up with concerning my use of class defs and
methods (S4 Reference Classes and S4 methods).

MY GOAL:
I thought it'd be neat to have Reference Class instances that can
- load data from remote places (e.g. a db, file whatever) on demand
- enable field access in a static OR dynamic way:
   o static -> regular "static" field access (or if not initialized yet:
retrieve data (optionally buffer it) -> write it to "static" field)
   o dynamic -> retrieve data (as it might have changed in the remote
location in the meantime) and optionally buffer it for later use
- enable sync of dynamic/buffer values with static field values (e.g.
whenever the difference between static and dynamic value passes threshold x
-> 
  sync static and dynamic values.
- Provide a value history (which might be useful for something ;-))
- Enable explicitly setting field values and facilitate their "writeback" to
the remote location

The instances should be flexible enough to work in an "static only" and
"dynamic only" context and should make as much use of existing functionality
(e.g. S4 classes, S4 method dispatch etc.) as possible. I do want to have
the choice if I'm carrying (possibly loads of) data with me in the fields of
my object or if I compute/get them based on some function whenever I
actually need it. For example, I'm thinking about parameter estimates that
could automatically be reestimated based on rules that take into account a
constantly changing data structure (new observations come it quite
frequently or something like that).
 
What do you think of the way I've implemented this? Does this make sense to
you or is something like this done in another (and probably more elegant
;-)) way?

THE HOMEWORK I DID
- I've looked at active bindings which are nice. But this limits me to funs
with either none or one argument if I'm not mistaken.
- I do like the idea of 'getRefClass("Blabla")$accessors(.)' setting up
get/set methods for me, but would need to customize them to my specific
needs 
  (e.g. handling the default values of method arguments etc.)

I've attached a code example and would really appreciate your comments if
you find some time.

Thanks a lot!!
Janko
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] WG: Reference classes: opinion on OOP design

2010-11-17 Thread Janko Thyson
Sorry, never sent an attachment before. I think my .R file didn't pass, so
I'm attaching a .txt instead.

-Ursprüngliche Nachricht-
Von: Janko Thyson [mailto:janko.thy...@ku-eichstaett.de] 
Gesendet: Mittwoch, 17. November 2010 19:56
An: 'r-de...@r-project. org'
Betreff: Reference classes: opinion on OOP design

Dear list,

I’m aware that this post does not really comply with the posting guide with
respect to “providing a minimal reproducible code example”. But I do hope
it’s okay that I spared uninterested readers by putting that into the
attachment ;-)

The thing is that I’m not really familiar with “true” OOP as R is my first
programming language. So I wanted to ask kindly for some expert opinion on a
certain paradigm I’ve come up with concerning my use of class defs and
methods (S4 Reference Classes and S4 methods).

MY GOAL:
I thought it’d be neat to have Reference Class instances that can
- load data from remote places (e.g. a db, file whatever) on demand
- enable field access in a static OR dynamic way:
   o static -> regular “static” field access (or if not initialized yet:
retrieve data (optionally buffer it) -> write it to “static” field)
   o dynamic -> retrieve data (as it might have changed in the remote
location in the meantime) and optionally buffer it for later use
- enable sync of dynamic/buffer values with static field values (e.g.
whenever the difference between static and dynamic value passes threshold x
-> 
  sync static and dynamic values.
- Provide a value history (which might be useful for something ;-))
- Enable explicitly setting field values and facilitate their “writeback” to
the remote location

The instances should be flexible enough to work in an "static only" and
"dynamic only" context and should make as much use of existing functionality
(e.g. S4 classes, S4 method dispatch etc.) as possible. I do want to have
the choice if I’m carrying (possibly loads of) data with me in the fields of
my object or if I compute/get them based on some function whenever I
actually need it. For example, I'm thinking about parameter estimates that
could automatically be reestimated based on rules that take into account a
constantly changing data structure (new observations come it quite
frequently or something like that).
 
What do you think of the way I’ve implemented this? Does this make sense to
you or is something like this done in another (and probably more elegant
;-)) way?

THE HOMEWORK I DID
- I’ve looked at active bindings which are nice. But this limits me to funs
with either none or one argument if I’m not mistaken.
- I do like the idea of ‘getRefClass(“Blabla”)$accessors(…)’ setting up
get/set methods for me, but would need to customize them to my specific
needs 
  (e.g. handling the default values of method arguments etc.)

I’ve attached a code example and would really appreciate your comments if
you find some time.

Thanks a lot!!
Janko
#---
# CLASS DEF
#---

Shabubu <- setRefClass(
Class="Shabubu",
fields=list(
BUFFER="environment",
HISTORY="environment",
DYNCNTRL="environment",
main="data.frame"
),
methods=list(
# GENERIC
GENERATOR=function() getRefClass("Shabubu"), 
fields=function() GENERATOR()$fields(),
methods=function() GENERATOR()$methods(),
#   accessors=function() GENERATOR()$accessors,
# /
# DATA RETRIEVAL
data.retrieve=function() data.retrieve.core(.self=.self),
# /
# BUFFER
buffer.refresh=function() assign("main", data.retrieve(), 
envir=BUFFER),  
buffer.clean=function() rm(list=ls(BUFFER, all.names=TRUE), 
envir=BUFFER),
# /
# DYNCNTRL
dyncntrl.set=function(field, arg, val)
{
if(!exists(field, DYNCNTRL)) 
assign(field, new.env(parent=emptyenv()), 
DYNCNTRL)

assign(arg, val, get(field, DYNCNTRL))
cat(paste("Setting '", arg, "=", val, "' for field '", 
field, 
"'.", sep=""), sep="\n")
},
dyncntrl.get=function(field, arg)
{
if(!exists(field, DYNCNTRL)) return(NULL)
if(!exists(arg, get(field, DYNCNTRL))) return(NULL)

get(arg, get(field, DYNCNTRL))
},
# /
# STATIC
static.clean=function(field)
{
expr <- paste("cls <- class(", field, ")", sep="")
ev

Re: [Rd] Bug in agrep computing edit distance?

2010-11-17 Thread Dickison, Daniel
I downloaded and compiled the standalone TRE agrep command line program,
and I think I have a slightly better idea of what's going on.  Basically
R's agrep, like the command line tool, is matching all strings that
*contain* the pattern.  So, essentially, insertions before and after the
pattern is "free".

As far as I can tell, there isn't an option to require full-string matches
using the TRE library.  It should be possible to not use REG_LITERAL and
surround the pattern with ^ and $, but that would require escaping all
special characters in the original pattern.

Is this something worth pursuing?  (For my immediate needs I'll probably
create a separate function that passes the regex directly to TRE without
REG_LITERAL).

Daniel

On 11/17/10 11:47 AM, "Joris Meys"  wrote:

>It might have to do something with spaces and the interpretation of
>insertions, as far as I understand the following examples :
>
>> agrep("x",c("x","xy","xyz","xyza"),max=list(all=1))
>[1] 1 2 3 4
>> agrep("x",c("x","xy  ","xyz ","xyza"),max=list(all=1))
>[1] 1
>> agrep("xx",c("xx","xyx","xyzx","xyzax",max=list(all=1)))
>[1] 1 2 3 4
>> agrep("xx",c("xx","xyx","xyzx","xyzax",max=list(ins=1)))
>[1] 1 2 3 4
>> agrep("xx   ",c("xx   ","xyx  ","xyzx ","xyzax",max=list(all=2)))
>[1] 1
>> agrep("xx   ",c("xx   ","xyx  ","xyzx ","xyzax",max=list(all=3)))
>[1] 1
>
>If the sequences are made the same length in spaces, this function
>gives the expected result in the second example, but it definitely
>doesn't do that any more when you start playing around with
>insertions. If not a bug, it definitely behaves pretty weird...
>
>Cheers
>Joris
>
>On Wed, Nov 17, 2010 at 4:49 PM, Dickison, Daniel
> wrote:
>> I posted this yesterday to r-help and Ben Bolker suggested reposting it
>> here...
>>
>> Dickison, Daniel  carnegielearning.com> writes:
>>
>>>
>>> The documentation for agrep says it uses the Levenshtein edit distance,
>>> but it seems to get this wrong in certain cases when there is a
>>> combination of deletions and substitutions.  For example:
>>>
>>> > agrep("abcd", "abcxyz", max.distance=1)
>>> [1] 1
>>>
>>> That should've been a no-match.  The edit distance between those
>>>strings
>>> is 3 (1 substitution, 2 deletions), but agrep matches with max.distance
=
>>> 1.
>>>
>>> I didn't find anything in the bug database, so I was wondering if
>>>somehow
>>> I'm misinterpreting how agrep works.  If not, should I file this in
>>> Bugzilla?
>>>
>>
>>  Could you re-post this on r-devel?  It definitely sounds like
>> this is worth following up.  Based on a little bit of playing around,
>> it's quite clear that I don't understand what's going on.  The examples
>> show things like
>>
>> agrep("lasy","lazy",max=list(sub=0))
>>
>>  which makes sense, but
>>
>> agrep("lasy","lazybc",max=1)
>> agrep("lasy","lazybc",max=0.001)
>> agrep("lasy","layt",max=list(all=1))
>>
>> and
>>
>> agrep("x",c("x","xy","xyz","xyza"),max=list(insertions=2))
>> agrep("x",c("x","xy","xyz","xyza"),max=list(deletions=2))
>> agrep("x",c("x","xy","xyz","xyza"),max=list(all=2))
>>
>>  all give "1 2 3 4" ??
>>
>>  this makes it clear that I really don't understand what's going on
>> based on the documentation.  I tried to trace into the C code
>> (which calls functions from the TRE regexp library) but that didn't
>> help much ...
>>
>>
>>
>> Daniel  Dickison
>> Research Programmer
>> ddicki...@carnegielearning.com
>> Toll Free: (888) 851-7094 x103
>> FAX: (412) 690-2444
>>
>> Revolutionary Math Curricula. Revolutionary Results.
>>
>> Carnegie Learning, Inc. | 437 Grant St. 20th Floor | Pittsburgh, PA
>>15219
>> www.carnegielearning.com
>>
>> __
>> R-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>
>
>
>-- 
>Joris Meys
>Statistical consultant
>
>Ghent University
>Faculty of Bioscience Engineering
>Department of Applied mathematics, biometrics and process control
>
>tel : +32 9 264 59 87
>joris.m...@ugent.be
>---
>Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

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


Re: [Rd] Bug in agrep computing edit distance?

2010-11-17 Thread Charles C. Berry

On Wed, 17 Nov 2010, Dickison, Daniel wrote:


I downloaded and compiled the standalone TRE agrep command line program,
and I think I have a slightly better idea of what's going on.  Basically
R's agrep, like the command line tool, is matching all strings that
*contain* the pattern.  So, essentially, insertions before and after the
pattern is "free".

As far as I can tell, there isn't an option to require full-string matches
using the TRE library.  It should be possible to not use REG_LITERAL and
surround the pattern with ^ and $, but that would require escaping all
special characters in the original pattern.

Is this something worth pursuing?  (For my immediate needs I'll probably
create a separate function that passes the regex directly to TRE without
REG_LITERAL).



I am joining this thread late, but I wonder if reversing agrep's 'pattern' 
and 'x' args serves the OP's need.


viz.


sapply( c("x","xy","xyz","xyza"),

+ function(y) any( agrep( y, "x", max=list(all=1
xxy   xyz  xyza
 TRUE  TRUE FALSE FALSE


HTH,

Chuck



Daniel

On 11/17/10 11:47 AM, "Joris Meys"  wrote:


It might have to do something with spaces and the interpretation of
insertions, as far as I understand the following examples :


agrep("x",c("x","xy","xyz","xyza"),max=list(all=1))

[1] 1 2 3 4

agrep("x",c("x","xy  ","xyz ","xyza"),max=list(all=1))

[1] 1

agrep("xx",c("xx","xyx","xyzx","xyzax",max=list(all=1)))

[1] 1 2 3 4

agrep("xx",c("xx","xyx","xyzx","xyzax",max=list(ins=1)))

[1] 1 2 3 4

agrep("xx   ",c("xx   ","xyx  ","xyzx ","xyzax",max=list(all=2)))

[1] 1

agrep("xx   ",c("xx   ","xyx  ","xyzx ","xyzax",max=list(all=3)))

[1] 1

If the sequences are made the same length in spaces, this function
gives the expected result in the second example, but it definitely
doesn't do that any more when you start playing around with
insertions. If not a bug, it definitely behaves pretty weird...

Cheers
Joris

On Wed, Nov 17, 2010 at 4:49 PM, Dickison, Daniel
 wrote:

I posted this yesterday to r-help and Ben Bolker suggested reposting it
here...

Dickison, Daniel  carnegielearning.com> writes:



The documentation for agrep says it uses the Levenshtein edit distance,
but it seems to get this wrong in certain cases when there is a
combination of deletions and substitutions.  For example:


agrep("abcd", "abcxyz", max.distance=1)

[1] 1

That should've been a no-match.  The edit distance between those
strings
is 3 (1 substitution, 2 deletions), but agrep matches with max.distance

=

1.

I didn't find anything in the bug database, so I was wondering if
somehow
I'm misinterpreting how agrep works.  If not, should I file this in
Bugzilla?



 Could you re-post this on r-devel?  It definitely sounds like
this is worth following up.  Based on a little bit of playing around,
it's quite clear that I don't understand what's going on.  The examples
show things like

agrep("lasy","lazy",max=list(sub=0))

 which makes sense, but

agrep("lasy","lazybc",max=1)
agrep("lasy","lazybc",max=0.001)
agrep("lasy","layt",max=list(all=1))

and

agrep("x",c("x","xy","xyz","xyza"),max=list(insertions=2))
agrep("x",c("x","xy","xyz","xyza"),max=list(deletions=2))
agrep("x",c("x","xy","xyz","xyza"),max=list(all=2))

 all give "1 2 3 4" ??

 this makes it clear that I really don't understand what's going on
based on the documentation.  I tried to trace into the C code
(which calls functions from the TRE regexp library) but that didn't
help much ...



Daniel  Dickison
Research Programmer
ddicki...@carnegielearning.com
Toll Free: (888) 851-7094 x103
FAX: (412) 690-2444

Revolutionary Math Curricula. Revolutionary Results.

Carnegie Learning, Inc. | 437 Grant St. 20th Floor | Pittsburgh, PA
15219
www.carnegielearning.com

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





--
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php


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



Charles C. BerryDept of Family/Preventive Medicine
cbe...@tajo.ucsd.eduUC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

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


Re: [Rd] Bug in agrep computing edit distance?

2010-11-17 Thread Dickison, Daniel
On 11/17/10 6:06 PM, "Joris Meys"  wrote:

>Indeed, I get it. If the pattern is "xx", it is only matched against 2
>letters at the same time. All the rest doesn't matter. But still that
>doesn't explain
>
>>agrep("ANNTCG", "ANNXXTCG", max = list(ins=3))
>integer(0)
>>agrep("ANNTCG", "ANNXTCG", max = list(ins=3))
>[1] 1
>>agrep("ANNTCG", "ANTCG", max = list(del=3))
>[1] 1
>>agrep("ANNTCG", "ATCG", max = list(del=3))
>integer(0)

It looks like R's agrep defaults max.distance$all to 0.1 if unspecified by
the argument, so that explains these examples (the first and last one have
a net distance of 2, which is > ceiling(0.1 * nchar(pattern))).

The attachment is a completely untested fix that turns the pattern into a
regex (I haven't yet succeeded in setting up an environment to compile R
from source).  Since TRE defaults to Basic POSIX regex syntax, in theory
only backslashes in the user-provided pattern need to be escaped, and \^
and \$ added to the pattern.  Hopefully somebody can review this to see if
it looks correct.

Daniel



Daniel  Dickison
Research Programmer
ddicki...@carnegielearning.com
Toll Free: (888) 851-7094 x103
FAX: (412) 690-2444

Revolutionary Math Curricula. Revolutionary Results.

Carnegie Learning, Inc. | 437 Grant St. 20th Floor | Pittsburgh, PA 15219
www.carnegielearning.com

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


[Rd] Performance monitoring tools

2010-11-17 Thread Patrick Leyshock
Hello,

Are there any good tools available for monitoring the performance of R?  I'm
wanting to capture things such as time elapsed in evaluating an expression,
memory usage over time (or operation), and so on.

I could build my own but would like to follow established practice, if there
is one.

Thank you,

Patrick

[[alternative HTML version deleted]]

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


Re: [Rd] Performance monitoring tools

2010-11-17 Thread Brian G. Peterson
On Wed, 17 Nov 2010 17:04:46 -0800, Patrick Leyshock 
wrote:
> Hello,
> 
> Are there any good tools available for monitoring the performance of R?
I'm
> wanting to capture things such as time elapsed in evaluating an
expression,
> memory usage over time (or operation), and so on.
> 
> I could build my own but would like to follow established practice, if
> there is one.

Start with Chapter 3 of the "Writing R Extensions" manual
"Tidying and profiling R code"

Regards,

  - Brian

-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock

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