Skip to content
Prev 25595 / 398502 Next

Use of variables to reference to objects

The "get" function is the usual answer to this sort of question, but is 
not right
for this particular case.  Actually, a simpler answer works.

lines(spectral$Wavelength, spectral[[ paste("a", j, sep="") ]], col=j)

Using "get" would want to get objects with names like "spectral$a1"
rather than the "a1" component of "spectral".



Patrick Burns
patrick at burns-stat.com
+44 (0) 208 525 0696
http://www.burns-stat.com/    (new home of S Poetry)
Kris Nackaerts wrote:

            
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._