Functions are not subroutines; that is, the effects (including assignments) are not global.
You need something like F <- function(x) x A <- F(3) But that seems unnecessary... A <- 3 Michael On Apr 25, 2012, at 10:06 PM, michaelyb <cel81009...@gmail.com> wrote: > Hello, > > I am trying to understand why the FUNCTION used in several codes, won't > create the object after it finishes running the code. > For instance, look at the following: > > Number<- function(x) {MyNumberIs<-x} > > When I run > Number(5) > Everything goes well, except that if I try to call the object MyNumberIs, I > won't find it. > > I understand that this function can assume many parameters, but why won't it > create the object? > > Besides, if I try "assing", it won't work either, no matter how I do it. > > Any advice/explanation? > > Thankk you very much! > > -- > View this message in context: > http://r.789695.n4.nabble.com/understanding-the-FUNCTION-function-tp4588681p4588681.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.