[R] understanding the FUNCTION function

michaelyb cel81009759 at gmail.com
Thu Apr 26 21:40:28 CEST 2012


David - 
My question to you may sound (actually, it really is) silly, but please do
take your time to answer it.

What is the difference between:
 fac<-function(x){a<-1
                for (i in 1:x){
                 a<-a*i
                  }a}

and:

 fac<-function(x){a<-1
                  for (i in 1:x){
                  a<-a*i
                  }
                  a}
I did try the first one, but I got an error message, so I thought I was
doing something wrong. However, once it finishes the loop, why the
difference between the last lines?

Best wishes!
Mike

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



More information about the R-help mailing list