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?
[object Object] is a string version of an object instance. This value is returned by a JavaScript program if you try to print out an object without first formatting the object as a string.
Pass by value means "What you get is the value of the parameter", and pass by reference means "What you get is a reference/alias of the parameter", independently of what the compiler really does (Copying, moving, eliding copies, passing pointers, passing references, etc).
The constructor for an Error object expects a string, not an object (which is why your scheme doesn't work). You are free to add your own custom properties to the Error object after you create it. let err = new Error('Email already exists'); err. status = 400; err.
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 evaluated
lower, upper
it 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 c as @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.
to reurn two or more results, use "c"
dummy <- function(){
a <- 1
b <- 22
return(a,b)
}
dummy()
# Error in return(a, b) : multi-argument returns are not permitted
dummy2 <- function(){
a <- 1
b <- 22
return(c(a,b))
}
dummy2()
# [1] 1 22
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With