Re: [R] within: order of newly added variables

2009-09-02 Thread Duncan Murdoch
On 9/2/2009 1:31 PM, Peter Ehlers wrote: Heinrich, You could create your own function mywithin() by inserting a couple of rev()'s in within.data.frame(). In within.data.frame(), replace the two commented lines with those immediately following: mywithin <- function (data, expr, ...) { pare

Re: [R] within: order of newly added variables

2009-09-02 Thread Gabor Grothendieck
On Wed, Sep 2, 2009 at 9:27 AM, RINNER Heinrich wrote: > Dear R community, > > I am using function 'within' in R.2.9.1 to add variables to an existing > data.frame. This works wonderful, except for one minor point: The new > variables are added to the data in reverse order. > > For example: > x <

Re: [R] within: order of newly added variables

2009-09-02 Thread Peter Ehlers
Heinrich, You could create your own function mywithin() by inserting a couple of rev()'s in within.data.frame(). In within.data.frame(), replace the two commented lines with those immediately following: mywithin <- function (data, expr, ...) { parent <- parent.frame() #e <- evalq(enviro

Re: [R] within: order of newly added variables

2009-09-02 Thread Duncan Murdoch
On 9/2/2009 9:27 AM, RINNER Heinrich wrote: Dear R community, I am using function 'within' in R.2.9.1 to add variables to an existing data.frame. This works wonderful, except for one minor point: The new variables are added to the data in reverse order. For example: x <- data.frame(a = 1:3, b

Re: [R] within: order of newly added variables

2009-09-02 Thread Henrique Dallazuanna
Try this: transform(transform(x, c = a ^ 2, d = b ^2), e = c + d) On Wed, Sep 2, 2009 at 10:27 AM, RINNER Heinrich < heinrich.rin...@tirol.gv.at> wrote: > Dear R community, > > I am using function 'within' in R.2.9.1 to add variables to an existing > data.frame. This works wonderful, except for

[R] within: order of newly added variables

2009-09-02 Thread RINNER Heinrich
Dear R community, I am using function 'within' in R.2.9.1 to add variables to an existing data.frame. This works wonderful, except for one minor point: The new variables are added to the data in reverse order. For example: x <- data.frame(a = 1:3, b = 4:6) y <- within(x, { c = a^2 d =