[R] understanding the FUNCTION function

michaelyb cel81009759 at gmail.com
Thu Apr 26 20:16:34 CEST 2012


Ista,

Since you seem to know your stuff very well, how would you get 120 out of a
function that gives you the factorial of 5, without using factorial(5)?

> Meanwhile, look at this example instead: 
> fac<-function(x){a<-1 
>                 for(i in 1:x){ 
>                 a<-a*i 
>                 print(a)}} 

gives you 120, but you cannot access it after the end of execution.


--
View this message in context: http://r.789695.n4.nabble.com/Using-FUNCTION-to-create-usable-objects-tp4588681p4590549.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list