[R] Changing Attribute With Paste
Sparks, John James
jspark4 at uic.edu
Sat May 14 10:14:00 CEST 2011
Dear R Helpers,
I am trying to adjust the attribute of an R object pulled from quantmod.
Since I want to do this for many such objects, I was trying to make the
adjustment programmatic. Unfortunately, I am having a huge amount of
trouble using attr in combination with paste (and perhaps get, and perhaps
assign, none of which seem to help). When I hard-code the change it works
fine. Your help would be much appreciated.
require(quantmod)
getFin("NYSE:A")
attr(NYSE.A.f,"symbol")<-"A" #works fine
ticker<-"A"
attr(paste("NYSE.",ticker,".f",sep=""),"symbol")<-"A" #doesn't work
attr(get(paste("NYSE.",ticker,".f",sep="")),"symbol")<-"A" #nor does
this, nor the hundred other combinations I have tried
Best wishes,
--John J. Sparks, Ph.D.
More information about the R-help
mailing list