[R] Help with "For" instruction

Sarah Goslee sarah.goslee at gmail.com
Tue Jan 4 19:12:13 CET 2011


You need to swap the get and paste commands -
paste() creates the string filename that get() acts on.

As already explained, using a list is much nicer.

Sarah

2011/1/4 André Dias <diasandre at gmail.com>:
> Hi
>
> I was doing
>
> for (i in 1:length(database))
> assign(paste("distancematrix",i,sep=""), dist(paste(get("database", i,
> sep="")))))
>
> but i really did not know what I was doing. I will try your way. But I still
> don't understnad how the get function works.
>
> What woud be more r-ish then get() ?
>
> thanks
> ADias
>
-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list