Re: [Rd] proto and baseenv()

2010-02-25 Thread Peter Danenberg
Quoth Ben Escoto on Sweetmorn, the 56th of Chaos: > I'm new to proto, but it seems like this is also a big drawback: > > > z <- 1 > > proto(baseenv(), expr={a=z})$a > Error in eval(expr, envir, enclos) : object "z" not found Ouch, good point; it may be that parent pollution is the lesser of two e

Re: [Rd] proto and baseenv()

2010-02-25 Thread Gabor Grothendieck
That is how R works with free variables, e.g. z <- 1 f <- function() z f() # 1 so the current behavior seems consistent with the rest of R. Note that the example below could be done like this to avoid the error: > z <- 1 > proto(baseenv(), a = z)$a [1] 1 On Thu, Feb 25, 2010 at 12:33 AM, Ben

Re: [Rd] proto and baseenv()

2010-02-25 Thread Thomas Petzoldt
Am 25.02.2010 06:33, wrote Ben: Wow, thanks for the heads-up. That is horrible behavior. But using baseenv() doesn't seem like the solution either. I'm new to proto, but it seems like this is also a big drawback: z<- 1 proto(baseenv(), expr={a=z})$a Error in eval(expr, envir, enclos) : obje

[Rd] wishlist: Clarify how to auto-load libraries at R start-up (PR#14224)

2010-02-25 Thread jgibson
Full_Name: Joe Gibson Version: 2.9.2 OS: Windows Submission from: (NULL) (12.229.76.26) I am new to R. Setting up R for my epidemiology department, I want users to have access to ggplot2 functions without having to remember to load that library before using the functions. It was very challengin

Re: [Rd] proto and baseenv()

2010-02-25 Thread Ben
I was disappointed in this behavior because it seems error-prone. Suppose I declare an environment > b <- 1 > p <- proto(expr={ a <- 2 + ... + }) > p$a [1] 2 > p$b [1] 1 Presumably if I ask for p$a or p$b later, it's because I'm interesting in the value of "p$a" or "p$b" that I specifically

Re: [Rd] scale(x, center=FALSE) (PR#14219)

2010-02-25 Thread Ben Bolker
bgsu.edu> writes: > scale returns incorrect values when center=FALSE and scale=TRUE. > > When center=FALSE, scale=TRUE, the "scale" used is not > the square root of sample > variance, the "scale" attribute is equal to sqrt(sum(x^2)/(n-1)). > > Example: > > x <- runif(10) > n <- length(x) >

Re: [Rd] proto and baseenv()

2010-02-25 Thread Duncan Murdoch
On 25/02/2010 8:50 AM, Ben wrote: I was disappointed in this behavior because it seems error-prone. Suppose I declare an environment > b <- 1 > p <- proto(expr={ a <- 2 + ... + }) > p$a [1] 2 > p$b [1] 1 Presumably if I ask for p$a or p$b later, it's because I'm interesting in the value o

Re: [Rd] proto and baseenv()

2010-02-25 Thread hadley wickham
> Presumably if I ask for p$a or p$b later, it's because I'm interesting > in the value of "p$a" or "p$b" that I specifically put inside that > environment.  Otherwise I would just ask for "a" or "b".  If I'm > asking for "p$b" it the above case, that means I forgot to declare b > inside p.  In thi

Re: [Rd] grid unit bug? (PR#14220)

2010-02-25 Thread Bert Gunter
Thank you Brian: Maybe I should follow my own advice! I DID check methods(is.numeric) to see if that were the case, but concluded it was not as that yielded an error. But all I needed to do was read the docs! Registering the method indeed seems the right way to do it. Best regards, Bert Gunter G

Re: [Rd] proto and baseenv()

2010-02-25 Thread Gabor Grothendieck
On Thu, Feb 25, 2010 at 9:57 AM, hadley wickham wrote: >> Presumably if I ask for p$a or p$b later, it's because I'm interesting >> in the value of "p$a" or "p$b" that I specifically put inside that >> environment.  Otherwise I would just ask for "a" or "b".  If I'm >> asking for "p$b" it the abov

[Rd] build, data and vignettes

2010-02-25 Thread Kasper Daniel Hansen
Based on some testing it seems to me that if I have a package with a dataset in /data a Sweave vignette in inst/doc (but no associated pdf file) the vignette loads the data in /data through data(dataset) and I do a R CMD build R will try to build the pdf version of the vignette, but wi

Re: [Rd] proto and baseenv()

2010-02-25 Thread Peter Danenberg
Quoth hadley wickham on Sweetmorn, the 56th of Chaos: > You might want to have a look at the mutatr package which implements > prototype OO with the behaviour you're looking for (I think). Hey, Hadley; I remember your prototype stuff from DSC 2009. I saw some slides of yours that discussed proto,

Re: [Rd] proto and baseenv()

2010-02-25 Thread Peter Danenberg
Quoth Gabor Grothendieck on Sweetmorn, the 56th of Chaos: > I think his objection is really only that he must specify baseenv() > to get the behavior he prefers but from what I understand (I am > basing this on my understanding that mutatr works like io language) > in mutatr one must use Object whi

Re: [Rd] proto and baseenv()

2010-02-25 Thread hadley wickham
> Hey, Hadley; I remember your prototype stuff from DSC 2009. I saw some > slides of yours that discussed proto, and was wondering whether mutatr > was still maintained. Yes, it's maintained, and I've even written a package that uses it (testthat - both it and mutatr are available on cran). It's

Re: [Rd] proto and baseenv()

2010-02-25 Thread Ben
> I think you are looking for a different object model than proto > offers. There aren't many languages that offer the prototype object > model. Yes, your probably right---I don't have much experience using the prototype model. This is the way I expected it to work: > z <- 1 > p <- proto(expr={

Re: [Rd] proto and baseenv()

2010-02-25 Thread hadley wickham
On Thu, Feb 25, 2010 at 7:49 PM, Ben wrote: >> I think you are looking for a different object model than proto >> offers.  There aren't many languages that offer the prototype object >> model. > > Yes, your probably right---I don't have much experience using the > prototype model.  This is the way

Re: [Rd] proto and baseenv()

2010-02-25 Thread Peter Danenberg
> > I think you are looking for a different object model than proto > > offers. There aren't many languages that offer the prototype object > > model. > > Yes, your probably right---I don't have much experience using the > prototype model. This is the way I expected it to work: > > > z <- 1 > >

Re: [Rd] proto and baseenv()

2010-02-25 Thread Gabor Grothendieck
On Thu, Feb 25, 2010 at 9:23 PM, Peter Danenberg wrote: >> > I think you are looking for a different object model than proto >> > offers.  There aren't many languages that offer the prototype object >> > model. >> >> Yes, your probably right---I don't have much experience using the >> prototype mo

Re: [Rd] proto and baseenv()

2010-02-25 Thread Peter Danenberg
> Your preference is inconsistent with how the rest of R works and is > inflexible since everything inherits from Object. Really? Here are a couple of counterexamples in S3 and S4 objects: > z <- 1 > > ## S4 > setClass('A', representation(a='numeric')) [1] "A" > a <- new('A', a=z) >

Re: [Rd] proto and baseenv()

2010-02-25 Thread Gabor Grothendieck
On Thu, Feb 25, 2010 at 11:16 PM, Peter Danenberg wrote: >> Your preference is inconsistent with how the rest of R works and is >> inflexible since everything inherits from Object. > > Really? Here are a couple of counterexamples in S3 and S4 objects: > >  > z <- 1 >  > >  > ## S4 >  > setClass('A

Re: [Rd] proto and baseenv()

2010-02-25 Thread Peter Danenberg
> Also other object systems which are alternatives to proto seem less > relevant than basic scoping and free variable lookup in functions. Sorry, but that seems absurd; object systems are less relevant to each other than the totally orthogonal question of scope? > proto does that but uses the con