Using EeethB's data set from above, I'd do the following:
mydata <- tibble(B1 = 1:2, B2 = 3:4, B4 = c(1, NA))
mydata$A1 <- ifelse(is.na(mydata$B4) ,(mydata$B1 + mydata$B2) /2,"")
I think you need to specify the last argument of ifelse, as in you need to decide what goes into A1 if the observation in B4 is not NA. Obviously EeethB's elegant solution works well too