Question

I have a panel dataset for which I have created lagged variables using the lag() function. When I try to calculate the delta for each timepoint, using the mutate command below, I get the error message "Error: not a promise"

> kw.lags[,c("imps", "lag1_imps", "lag2_imps")]
Source: local data frame [157,737 x 3]
Groups: 

   imps lag1_imps lag2_imps
1    65        NA        NA
2    79        65        NA
3    62        79        65
4    69        62        79
5     1        NA        NA
6     2        NA        NA
7     2         2        NA
8     1         2         2
9     2         1         2
10    5        NA        NA
..  ...       ...       ...

> kw.deltas <- mutate(kw.lags, 
+   d1_imps = imps - lag1_imps,
+   d2_imps = imps - lag2_imps,
+   d3_imps = imps - lag3_imps,
+ )
Error: not a promise  
Was it helpful?

Solution

You have a comma after the last line in your mutate statement. Try to remove that, and see if it fixes the error.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top