you have syntax errors, you can''t follow and if() with if() directly without intervening symbols, you need to use curly braces to nest. I wonder about your working example for the case of 3, did you not face the same issue ?
Anyway, here is a version that avoids the need to heavily nest...
minimum4 <- function(a,b,c,d){
if(d<=a & d<=b & d<= c) d
else if(c<=a & c<=b & c<= d) c
else if(b<=a & b<=c & b<= d) b
else if(a<=b & a<=c & a<= d) a
}
I would also not use this code in my real work, rather, I would use min()