I am wondering how can I do this thing work:
features_windows <- function(data, window_size) {
data_with_feature <- data %>%
mutate(window_one = nrow(data[data$ID<ID & data$key==key & data$ID > ID - window_size,]))
data_with_feature
}
Basically the new feature should be how much points are there in the time-window ID-window_size : ID with the key. Currently I am getting 0s everywhere and for loop is a terrible idea in R. Any ideas?
Regards, T