[R] Local Variable

harunpirim harunpirim at gmail.com
Thu Sep 16 17:36:16 CEST 2010


Dear All,

I have a function:

gen <- function(m){for(i in 1:m){assign(paste("x",i, sep=""),
(7*get(paste("x",i-1,sep="")))%%13); print(get(paste("x", i, sep="")))}}

my question is, I do gen(20), then the function prints out 20 values,
however when I do objects(), I can't see x1,x2,x3,....,x20 as objects. Why?
Are they local variables? R doesn't show local variables as objects?

Thanks,

Harun
-- 
View this message in context: http://r.789695.n4.nabble.com/Local-Variable-tp2542441p2542441.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list