[R] Using a FOR LOOP to name objects

michaelyb cel81009759 at gmail.com
Wed Feb 29 04:40:48 CET 2012


Hello,

I am trying to use a for loop to name objects in each iteraction. As in the
following example (which doesn't work quite well)

my_list<-c("A","B","C","D","E","F")
for(i in c(1:length(my_list))){
  url<- "http://finance.yahoo.com"
  doc = htmlTreeParse(url, useInternalNodes = T)
  tab_nodes = xpathApply(doc, "//table[@cellpadding = '3']")
  *my_list[i]*=lapply(tab_nodes, readHTMLTable)     #problem is in this line
  names(*my_list[i]*)=c("Ins","outs")
  }

The problem is that in iteraction #1, I need the info to be stored at an
object called "A"; At iteraction #2 at object called "B"... and so on....

Any idea/help?

thank you in advance!

--
View this message in context: http://r.789695.n4.nabble.com/Using-a-FOR-LOOP-to-name-objects-tp4430454p4430454.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list