Questions tagged «multiple-results»

13
如何从一个返回多个值的函数中赋值?
仍在尝试进入R逻辑...解包(在LHS上)返回多个值的结果的“最佳”方法是什么? 我显然不能这样做: R> functionReturningTwoValues <- function() { return(c(1, 2)) } R> functionReturningTwoValues() [1] 1 2 R> a, b <- functionReturningTwoValues() Error: unexpected ',' in "a," R> c(a, b) <- functionReturningTwoValues() Error in c(a, b) <- functionReturningTwoValues() : object 'a' not found 我真的必须执行以下操作吗? R> r <- functionReturningTwoValues() R> a <- r[1]; …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.