structure(list(PROD_DATE = structure(c(1465876800, 1465963200,
1466049600, 1466136000, 1466222400, 1466308800, 1466395200, 1466481600,
1466568000, 1466654400), class = c("POSIXct", "POSIXt"), tzone = ""),
FILENUM = c(51922L, 51922L, 51922L, 51922L, 51922L, 51922L,
51922L, 51922L, 51922L, 51922L), CHOKE_SETTING = c(16L, 18L,
50L, 40L, 30L, 23L, 29L, 32L, 35L, 30L)), .Names = c("PROD_DATE",
"FILENUM", "CHOKE_SETTING"), row.names = c(NA, -10L), class = c("grouped_df",
"tbl_df", "tbl", "data.frame"), vars = "FILENUM", drop = TRUE, indices = list(
0:9), group_sizes = 10L, biggest_group_size = 10L, labels = structure(list(
FILENUM = 51922L), row.names = c(NA, -1L), class = "data.frame", vars = "FILENUM", drop = TRUE, .Names = "FILENUM"))
df <- df %>% group_by(FILENUM) %>% arrange(PROD_DATE) %>%
mutate(DAYS_ON = row_number())
I'm using the code above to start numbering the rows of the dataset to count days since the start. Rather than using Date-time variable in prod_date.
I am unsure how to add another column that counts days since the occurrence of a max value in a different column. It should start counting the first row at the value of 50. Previous rows would either be NA or 0