-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Description
library(dplyr)
df = read.csv(text ='
name time
1 Rob 3
2 Pete 2
3 Rob 5
4 John 3
5 Rob 2
6 Pete 3
7 John 2
8 Pete 4
9 John 1
10 Pete 1
11 Rob 4
12 Rob 1
', sep='')
df %>% group_by(name) %>% mutate(lag_time = lag(time))
Gets me
name time lag_time
1 Rob 3 NA
2 Pete 2 NA
3 Rob 5 2
4 John 3 NA
5 Rob 2 3
6 Pete 3 2
7 John 2 3
8 Pete 4 2
9 John 1 4
10 Pete 1 1
11 Rob 4 1
12 Rob 1 4
Should row 3 be Rob 5 3? Is this a bug or intended behavior?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels