Re: [Rd] replicate evaluates its second argument in wrong environment

2021-02-15 Thread Hadley Wickham
On Monday, February 15, 2021, David Winsemius wrote: > > On 2/15/21 1:10 PM, Hadley Wickham wrote: > >> This is a nice example of the motivation for tidy evaluation — since >> enquo() captures the environment in which the promise should be >> evaluated, there's no need for an additional explicit

Re: [Rd] replicate evaluates its second argument in wrong environment

2021-02-15 Thread David Winsemius
On 2/15/21 1:10 PM, Hadley Wickham wrote: This is a nice example of the motivation for tidy evaluation — since enquo() captures the environment in which the promise should be evaluated, there's no need for an additional explicit argument. library(rlang) replicate2 <- function (n, expr, simpli

Re: [Rd] replicate evaluates its second argument in wrong environment

2021-02-15 Thread Hadley Wickham
This is a nice example of the motivation for tidy evaluation — since enquo() captures the environment in which the promise should be evaluated, there's no need for an additional explicit argument. library(rlang) replicate2 <- function (n, expr, simplify = "array") { exnr <- enquo(expr) sapply

[Rd] replicate evaluates its second argument in wrong environment

2021-02-13 Thread Gabor Grothendieck
Currently replicate used within sapply within a function can fail because it gets the environment for its second argument, which is currently hard coded to be the parent frame, wrong. See this link for a full example of how it goes wrong and how it could be made to work if it were possible to pass