Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 206278

How to store different outputs inside a funcion? [duplicate]

$
0
0

I want to store different output variables that are calculated inside a function. I coded a toy example:

f = function(number) 
{

  xx = NULL
  savexx = NULL
  savexx10 = NULL
  for (i in 1:10) {
  x = number*i
  xx = c(xx,x)
  }

  save_phrase = "hello"
  savexx = xx        
  savexx10 = xx*10
  save = cbind(savexx,savexx10)

}

store = f(1)
store

But with this code it is returning only the variable save = cbind(savexx,savexx10). I would like to save all the 4 variables that are created inside this function.

Is it possible doing this without using a dataframe or a list?


Viewing all articles
Browse latest Browse all 206278

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>