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
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
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
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
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
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)
>
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
> 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
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
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
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
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,
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
> 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
> 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={
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
> > 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
> >
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
> 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)
>
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
> 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
21 matches
Mail list logo