I'm exploring the simplest way to edit the vector below. I'd like to replace values from A and B with test values < 2 (0 or 1) with NA, then eliminate test columns. I know we could just replace them without conditionals but this example is to illustrate the problem from a much larger data frame.
> df <- data.frame(list(A=c(100, 30, 200, 80, 5), B=c(12, 40, 100,70,50), testA=c(17, 1, 120,400,70), testB=c(5, 4, 1, 10, 0)))
It looks like this:
A B testA testB
100 12 17 5
30 40 1 4
200 100 120 1
80 70 400 10
5 50 70 0
It should look like this:
A B
100 12
NA 40
200 NA
80 70
5 NA
Thank you in advance!