[R] how to replace text...

Sean Davis sdavis2 at mail.nih.gov
Fri Apr 29 13:11:39 CEST 2005


On Apr 29, 2005, at 6:11 AM, Jonathan Q. wrote:

> if I have....
>
> QQQQ<-priceIts("QQQQ",quote="Close")
> QQQQ<-priceIts("QQQQ",quote="Close");plot(QQQQ)
>
> and then i want to do the same thing but say with IBM instead of QQQQ
> is there an easy way like replace qqqq/ibm
>


You should probably use a list instead.  This is a FAQ (see 7.21):

http://cran.r-project.org/doc/FAQ/R-FAQ.html

Here is about how you might do it (untested):

pricelist <- list()

pricelist[['IBM']] <- pricelts('IBM',quote="Close")
pricelist[['QQQQ']] <- pricelts('QQQQ',quote="Close")

par(ask=T)
lapply(pricelist,plot)

Does this do what you want?

Sean




More information about the R-help mailing list