structure(list(datetime = structure(c(16512, 16513, 16514, 16517, 
16518, 16519, 16520, 16521, 16524, 16525, 16526, 16527, 16531, 
16532, 16533, 16534, 16535, 16538, 16539, 16540), class = "Date"), 
    asset = c("004125", "004125", "004125", "004125", "004125", 
    "004125", "004125", "004125", "004125", "004125", "004125", 
    "004125", "004125", "004125", "004125", "004125", "004125", 
    "004125", "004125", "004125"), investor = c("Q1762", "Q1762", 
    "Q1762", "Q1762", "Q1762", "Q1762", "Q1762", "Q1762", "Q1762", 
    "Q1762", "Q1762", "Q1762", "Q1762", "Q1762", "Q1762", "Q1762", 
    "Q1762", "Q1762", "Q1762", "Q1762"), marketprice = c(163, 
    165, 165, 165, 550, 555, 595, 540, 555, 555, 555, 534, 543, 
    165, 165, 165, 168.1, 168.1, 168.1, 168.1), corrprice = c(163, 
    165, 165, 165, 165, 555, 595, 540, 555, 555, 555, 534, 543, 
    165, 165, 165, 168.1, 168.1, 168.1, 168.1), ab_check = c(FALSE, FALSE, FALSE, FALSE, TRUE, 
    FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 
    FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), adjustm = c(1, 
    1, 1, 1, 3.33, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
    1, 1, 1, 1, 1), returns = c(NA, 
    0.0122699386503067, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0.0187878787878788, 0, 0, 0)), class = c("grouped_df", 
"tbl_df", "tbl", "data.frame"), row.names = c(NA, -20L), groups = structure(list(
    asset = "004125", .rows = structure(list(1:20), ptype = integer(0), class = c("vctrs_list_of", 
    "vctrs_vctr", "list"))), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -1L), .drop = TRUE))
Hello, I have this dataframe in which I have different asset. I need R when ab_check == TRUE, to take all the following observation, hence for all the next datetime, for that asset and divide the marketprice for the adjustm value corresponding to the ab_check == TRUE row.
So basically I want R to do: if ab_check == TRUE ==> marketprice(i)/adjustm(when ab_check == TRUE) where marketprice(i) must have a datetime >= datetime(ab_check == TRUE)
I'm learning dplyr and so I would prefer a dplyr solution if possible. Thank you!
 
    