I've seen some questions regarding the output of multiple objects from a function, however the suggestions all end up suggesting the use of return(list(result1=result1, result2=result2 , result3=result3)). How can I return multiple objects that are 2 big to be added to a list? -- View this message in context: http://r.789695.n4.nabble.com/Create-a-function-with-multiple-object-as-an-output-tp4074226p4074226.html Sent from the R help mailing list archive at Nabble.com.
Write an R program to draw 10,000 random samples using the Polya Urn Scheme where the initial contents of the urn is one white ball and one black ball. Accumulate the proportion of white balls after each draw into one vector. Upload your R script file. HINT: You can simulate sampling one ball from an urn with N balls of which w are white and N - w are black with the Binomial R function: rbinom(1,1,w/N). can someone assist me with the above code? -- View this message in context: http://r.789695.n4.nabble.com/Create-a-function-with-multiple-object-as-an-output-tp4074226p4074231.html Sent from the R help mailing list archive at Nabble.com.
Sarah Goslee
2011-Nov-16 02:09 UTC
[R] Create a function with multiple object as an output
Hi, On Tue, Nov 15, 2011 at 4:10 PM, anaraster <rrasterr at gmail.com> wrote:> I've seen some questions regarding the output of multiple objects from a > function, however the suggestions ?all end up suggesting the use of > return(list(result1=result1, result2=result2 , result3=result3)). > > How can I return multiple objects that are 2 big to be added to a list?I'm not sure what you mean: what kind of objects are too big to add to a list? An example would be useful here. A list is the correct way to return multiple results, and that's what R functions do, even the ones that return large objects. Sarah -- Sarah Goslee http://www.functionaldiversity.org
On 16/11/11 10:10, anaraster wrote:> I've seen some questions regarding the output of multiple objects from a > function, however the suggestions all end up suggesting the use of > return(list(result1=result1, result2=result2 , result3=result3)). > > How can I return multiple objects that are 2 big to be added to a list?This makes absolutely no sense at all. What on earth are you talking about? cheers, Rolf Turner