multiple-results

How to assign from a function which returns more than one value?

你说的曾经没有我的故事 提交于 2019-12-16 23:01:15
问题 Still trying to get into the R logic... what is the "best" way to unpack (on LHS) the results from a function returning multiple values? I can't do this apparently: 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 must I really do the following? R> r <-

Multiple results for one field in a joined SQL query

China☆狼群 提交于 2019-12-11 12:51:36
问题 I'm not sure if this is possible from with a SQL query, but I'll give it a go. I'm developing a SharePoint web part in C# that connects to a SQL database and runs a query, then databinds that result set to a gridview. It's working fine, but I have a small snag. For the most part, my query will return exactly one result for every field. I am displaying the information vertically, so it looks roughly like this: Customer Name Mr. Customer Customer Address 980 Whatever St. Customer City

How to assign from a function which returns more than one value?

落爺英雄遲暮 提交于 2019-11-26 02:39:21
Still trying to get into the R logic... what is the "best" way to unpack (on LHS) the results from a function returning multiple values? I can't do this apparently: 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 must I really do the following? R> r <- functionReturningTwoValues() R> a <- r[1]; b <- r[2] or would the R programmer write something more like