Skip to content
Prev 25568 / 398502 Next

Use of variables to reference to objects

Hi,

I'm new to R and looking for a way to use a variable to reference to an 
object.

I'm plotting several graphs on top of each other and want to do this by 
a for loop. The field I want to graph have names like a1,a2,a3, ...
I can't figure out how to get this working:

It should look like this:
lines(spectral$Wavelength,paste("spectral$a",j,sep=""),col=j)

but the "paste()" does not seem to work in this context.

Any help?

Kind regards,

Kris