You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Something is broken in the substitution of the wt parameter in the top_n helper function.
> iris %.%
+ group_by(Species) %.%
+ summarise(w=mean(Petal.Width)) %.%
+ top_n(1, w)
Error in top_n(`__prev`, 1, w) : object 'w' not found
The equivalent spelled out with filter(rank(...)) works fine
> iris %.%
+ group_by(Species) %.%
+ summarise(w=mean(Petal.Width)) %.%
+ filter(rank(w) <= 1)
Source: local data frame [1 x 2]
Species w
1 setosa 0.246
My experience with R at this level is limited, but I'm pretty sure the problem is that we're evaluating is.null(wt) at the beginning of the function; and adding wt <- substitute(wt) at the beginning will defer the evaluation sufficiently for this to work. EDIT: or using missing(wt) instead of is.null(wt)
The text was updated successfully, but these errors were encountered:
Something is broken in the substitution of the wt parameter in the top_n helper function.
The equivalent spelled out with
filter(rank(...))
works fineMy experience with R at this level is limited, but I'm pretty sure the problem is that we're evaluating
is.null(wt)
at the beginning of the function; and addingwt <- substitute(wt)
at the beginning will defer the evaluation sufficiently for this to work. EDIT: or usingmissing(wt)
instead ofis.null(wt)
The text was updated successfully, but these errors were encountered: