I am having the following dataset.
df <- data.frame(a = c(NA, NA, 1,5),
b = c(NA, NA, 2, 3),
c = c(NA, 5, NA, 5),
d = c(3, NA, NA, NA))
I want to average per row all these variables. But I want to R to return NA when there is only one value per each row.
How am I going to do that?
The results should look like that:
a b c d average
NA NA NA 3 NA
NA NA 5 NA NA
1 2 NA NA 1.5
5 3 5 NA 4,33
Thanks a lot