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
This is a follow up on #925 which fixed lag() on grouped data.
The same issue exists also for lead() when data is grouped and wasn't fixed yet in the current dev version:
df <- data.frame(name=rep(c('Al','Jen'),3),
score=rep(c(100, 80, 60),2))
df %>%
group_by(name) %>%
mutate(next.score = lead(score),
before.score = lag(score) )
# name score next.score before.score
#1 Al 100 80 NA
#2 Jen 80 60 NA
#3 Al 60 100 100
#4 Jen 100 80 80
#5 Al 80 NA 60
#6 Jen 60 NA 100
For instance, next.score for Al in line 1 should be 60 and not 80.
Following the fix of #925 I assume that Lead.h in line 52 needs to be modified from out[out_index[i]] = data[index[i]+n] ; to out[out_index[i]] = data[index[i+n]] ;
The text was updated successfully, but these errors were encountered:
Thanks for the feedback and the fix! You're right, I should have submitted a pull request. I doubt that there will be a second chance given the excellent state of the package :-).
Cheers,
Alex
lockbot
locked as resolved and limited conversation to collaborators
Jun 10, 2018
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
This is a follow up on #925 which fixed
lag()
on grouped data.The same issue exists also for
lead()
when data is grouped and wasn't fixed yet in the current dev version:For instance, next.score for Al in line 1 should be 60 and not 80.
Following the fix of #925 I assume that
Lead.h
in line 52 needs to be modified fromout[out_index[i]] = data[index[i]+n] ;
toout[out_index[i]] = data[index[i+n]] ;
The text was updated successfully, but these errors were encountered: