The assign()
function may be used with paste()
to create
function names in a loop. For example, suppose we have a list
my.list
of length n and we want to create variables x1,...,xn
each containing the component comp
of the corresponding element
of my.list
. This may be done using
for (i in 1:n) assign(paste("x",i,sep=""), my.list[i]$comp)
Go to the first, previous, next, last section, table of contents.