Both of these results are giving me the same answer/expected result. Is one method better than the other? Why doesn't method 1 require an else statement?
Method 1:
thisFunction <- function (n,p) {
if(n >= p)
return(n + p)
if(n < p)
return(n * p)
}
Method 2:
thisFunction <- function (n,p)
{
if (n >= p)
{
return(n+p)
}
else
{
return(n*p)
}
}