I'm running into an unexpected problem. Because I could swear this used to work.
I have a nested dataframe, with an "ID" column (n = 55) and a "Data" listcolumn. I wish to create another listcolumn which is a lagged version of the "Data" column.
nested_df <- nested_df %>% mutate(data_lag = map(.x = .$data, .f = lag, 1))
I get the following error
data_lag must be length 1 (the group size), not 55
doing the following works however:
nested_df$data_lag <- map(.x = nested_df$data, .f = lag, 1))
Where am I going wrong here?