Hi R comm.
If the "anomaly" column is == Yes then i want to replace the "observed" column with NA
dput:
structure(list(item_id = c("AS2008", "AS2008", "AS2008", "AS2008",
"AS2008", "AS2008", "AS2008", "AS2008", "AS2008", "AS2008", "AS2008",
"AS2008", "AS2008", "AS2008", "AS2008", "AS2008", "AS2008", "AS2008",
"AS2008", "AS2008", "AS2008", "AS2008", "AS2008", "AS2008", "AS2008",
"AS2008", "AS2008", "AS2008", "AS2008", "AS2008", "AS2008", "AS2008",
"AS2008", "AS2008", "AS2008", "AS2008", "AS2008", "AS2008", "AS2008",
"AS2008"), date = structure(c(18262, 18263, 18264, 18265, 18267,
18268, 18269, 18271, 18272, 18274, 18275, 18276, 18277, 18278,
18279, 18280, 18281, 18282, 18283, 18284, 18285, 18286, 18288,
18289, 18290, 18291, 18293, 18295, 18296, 18297, 18298, 18302,
18303, 18304, 18305, 18308, 18309, 18310, 18311, 18313), class = "Date"),
observed = c(NA, 4, 1, 1, 15, 5, 11, 0, 1, 13, 8, 2, 4, 4,
2, 2, 13, 6, 9, 2, 2, 2, 14, -1, 1, 4, 3, 12, 3, 5, 3, 29,
9, 3, 4, 6, 27, 9, 4, 5), anomaly = c(`25%` = "No", `25%` = "No",
`25%` = "No", `25%` = "No", `25%` = "No", `25%` = "No", `25%` = "No",
`25%` = "No", `25%` = "No", `25%` = "No", `25%` = "No", `25%` = "No",
`25%` = "No", `25%` = "No", `25%` = "No", `25%` = "No", `25%` = "No",
`25%` = "No", `25%` = "No", `25%` = "No", `25%` = "No", `25%` = "No",
`25%` = "No", `25%` = "No", `25%` = "No", `25%` = "No", `25%` = "No",
`25%` = "No", `25%` = "No", `25%` = "No", `25%` = "No", `25%` = "Yes",
`25%` = "No", `25%` = "No", `25%` = "No", `25%` = "No", `25%` = "No",
`25%` = "No", `25%` = "No", `25%` = "No")), row.names = c(NA,
-40L), groups = structure(list(item_id = "AS2008", .rows = structure(list(
1:40), ptype = integer(0), class = c("vctrs_list_of", "vctrs_vctr",
"list"))), row.names = c(NA, -1L), class = c("tbl_df", "tbl",
"data.frame"), .drop = TRUE), class = c("grouped_df", "tbl_df",
"tbl", "data.frame"))
also if someone have a good idea to impute the newly created NA's with some kind of imputation method please let me know
Thanks!