Hi Petr,

Thanks for the solution. But my problem is still there. I have 500 company names in a single column in an excel sheet of S&P 500 index. I need to call all those compnies in a 'for' loop and write that whole dataset into a text file. I've developed the following one, but the problem is getting all those company names in a vector.

h<-c("GE","MMM")
s<-matrix(0,3818,2)
for  (i in 1:2)
{
s[,i]<-yahoo.get.hist.quote(instrument = h[i], destfile = paste(h[i], ".csv", sep = ""), start="1996-01-01",
                     end="2006-06-16", quote = c("Close"), adjusted = TRUE, download = TRUE, origin = "1970-01-01",
                     compression = "d")
write.csv(s,file="Z:/yahoo.out.csv")
}

Here i have taken only two compnies. But i want to fetch all the company names and put them in a vector so that i can call them in a 'for' loop. Please guide.

Thanks,
Sumanta Basak.

Petr Pikal <petr.pikal@precheza.cz> wrote: Hi


On 16 Jun 2006 at 8:52, SUMANTA BASAK wrote:

Date sent:       Fri, 16 Jun 2006 08:52:22 +0100 (BST)
From:            SUMANTA BASAK 
To:              R HELP ,
 r-sig-finance-request@stat.math.ethz.ch
Subject:         [R] Yahoo data download problem

> Hi all R-Experts,
> 
> I'm facing one problem in yahoo data downloading. I'm suing Windows
> XP, R 2.2.0, and i'm using yahoo.get.hist.quote function to download
> data. I need 500 companies of S&P index daily 'closing price' data for
> last ten years. My questions are:
> 
> 1) I have all the ticker names of S&P 500 companies in a .csv format.
> I'm reading those names in R and they are coming as data.frame object.
> How can i change this to a vector?

df<-data.frame(x=sample(letters,10)) 

 as.vector(df$x)
 [1] "g" "b" "p" "u" "r" "q" "j" "h" "o" "k"
>

HTH
Petr


> 
> 2) How can i get all companies data downloaded using a simple "for"
> loop?
> 
> I'm using the following function for a single stock data.
> 
> 
> library(gdata)
> s<-yahoo.get.hist.quote(instrument = "mo", destfile = paste("mo",
> ".csv", sep = ""), start="1996-01-01",
>                      end="2006-06-16", quote = c("Close"), adjusted =
>                      TRUE, download = TRUE, origin = "1970-01-01",
>                      compression = "d")
> 
> 
> Thanks,
> Sumanta Basak.
> 
> 
> ---------------------------------
> 
> 
>  [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html

Petr Pikal
petr.pikal@precheza.cz



 				
---------------------------------


	[[alternative HTML version deleted]]

