dplyr::lead() not working correctly?

dplyr::lag() seems to work fine, but dplyr::lead() seems not to.work. Am I doing something wrong, or is this a bug? Running R 3.6.1, dplyr version 0.8.3 on uptodate Windows 10.
Thanks for the help. Larry Hunsicker

> junk <- data.frame(thing = 1:5)
> junk %<>% mutate(last = lag(thing, 1))
> junk
  thing last
1     1   NA
2     2    1
3     3    2
4     4    3
5     5    4
> junk %<>% mutate(next = lead(thing,1))
Error: unexpected '=' in "junk %<>% mutate(next ="

Sorry. My bad. Evidently "next" is a reserved word. "next1" works correctly.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.