I expected the following code to return the lower and upper bounds of a 95% confidence interval:
confint95 = function(mean, se)
{
confint = abs(se*1.96)
lower = abs(mean-cint)
upper = abs(mean+cint)
return(lower,upper)
}
But this gives this message:
Error in return(lower, upper) : multi-argument returns are not permitted
How can I set function to return the lower and upper bounds of a 95% confidence interval?
Function will return the last expression. If you think for a moment without
return. If you gave the function as the last expression to be evaluatedit would produce an error. If you have IDE it would also probably complain about a syntax error. You would solve that by combining the two elements with a
cas @Andrie indicated. Ergo, you need to pass a single object. I often use lists to output different data structures. In your case, a vector is more than sufficient.