Looking for some insight as to why I am getting the warning "number of items to replace is not a multiple of replacement length" with the simple code below (which does what I need it to do)?
A_DF <- data.frame(A = c(1,1,2,2,3,4), B = c(0,0,0,0,0,0))
A_DF <- A_DF %>% mutate(B = replace(B, A<=2, A), B = replace(B, A>2, 7))
Warning message:
In x[list] <- values :
number of items to replace is not a multiple of replacement length
Output:
A_DF
A B
1 1 1
2 1 1
3 2 2
4 2 2
5 3 7
6 4 7