I have a generic function which I want to get three values from. However it only returns one of the values from the "return" function. My code is structured like this:
doEverythingFunction <- function(x){
"do some esoteric calculations here"
return(valueX)
"do some more esoteric calculations here"
return(valueY)
"do even more esoteric calculations here"
return(valueZ)
}
This function only returns value Z and not X and Y. How can I get it to return all three values?
In R you can only return one object. You could put the three values in a list or a vector and then return that list or vector.
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