Test <- tribble(~Date, ~HCl_Konz, ~HCl_Kenn, ~CO_Konz, ~CO_Kenn,
1, 4, "", 4, "",
2, 5, "", 1, "",
3, 2, "X", 6, "BX",
4, 5, "", 4, "",
5, 6, "F", 4, "",
6, 5, "", 9, "EXr")
Param <- c("HCl", "CO")
The real tibble is much bigger and has several columns like the HCl and CO, but they all follow the same scheme. For all of these columns I want to set the value of HCl_Konz to NA, if the Column HCl_Kenn has at least one of the chars "X" or "F", the same with CO_Konz (if CO_Kenn includes X or F), and all the oder XXX_Konz columns.
I tried the following code, but it quits with the following error.
Test %>% rowwise() %>%
mutate(across(paste(Param, "_Konz", sep=""), ~ ifelse(str_detect(paste(str_sub(cur_column(),1,-6), "_Kenn", sep=""), "[XF]"), NA_real_, .x)))
The code doesn't throw an error, but the values are not replaced by NA.
tia