Closed hope-data-science closed 4 years ago
@hope-data-science
It seems you use lag
from base R which has very surprising behaviour:
lag(1:3)
# [1] 1 2 3
# attr(,"tsp")
# [1] 0 2 1
There is a special function shift
in the data.table package. It should work as you expect from lag
.
It is great design to have "by" parameter in
dt_mutate
anddt_summarise
, however, when I try:It did not work. Is there some way to make it work? Should we design a new API or just optimize it inside
dt_mutate
?