## Create a function to assign a series of values to a list of objects ## The assign function can only assign one value (could be a vector) to a name ## Set the environment to be global, otherwise the objects can't be used outside the function ## List objects that have been created
toto <- function(x,y) { for (i in x:y){ assign(paste("tot", i, sep=""), i*2, envir = .GlobalEnv) }} toto(3,7) ls(pattern = "^tot.$") ----- A R learner. -- View this message in context: http://r.789695.n4.nabble.com/writing-function-tp2224781p2225249.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.