Hello,

Use paste0(ticker[i], "_Divs.csv")

Rui Barradas
Em 17-10-2012 16:02, FJ M escreveu:
Thanks for this timely post for me. I'm missing something in cat to get file.rename to work for me. cat puts a NULL at the 
end of a string. Error: downloading  MSFT .....trying URL 
'http://chart.yahoo.com/table.csv?s=MSFT&a=1&b=19&c=2003&d=9&e=17&f=2012&g=d&q=q&y=0&z=MSFT&x=.csv'
Content type 'text/csv' length unknown
opened URL
downloaded 119 Kbdone.
MSFT _Divs.csvNULL
Error in file.rename("Stock_Divs.csv", file_name) : invalid 'to' argument
Execution halted
  Code: library(quantmod)##
## Merge Date OHLC with dividend on ex-dividend date
##
ticker<-c("MSFT","KMI")
Divs_Per_Year<-4for (i in 1:2)
{
Divs<-getDividends(ticker[i])
Stock<-getSymbols.yahoo(ticker[i], from = start(Divs), src = "yahoo", 
verbose=TRUE, auto.assign=FALSE)
Stock_Divs<-merge(Stock,Divs,fill=0.0)
write.zoo(Stock_Divs, file = "Stock_Divs.csv", append = FALSE, quote = TRUE, sep = 
",")
file_name<- cat(ticker[i],"_Divs.csv")
print(file_name)
print
file.rename("Stock_Divs.csv",file_name)
}
Best, FrankChicago
  > From: [email protected]
Date: Wed, 17 Oct 2012 13:47:27 +0100
To: [email protected]
CC: [email protected]; [email protected]
Subject: Re: [R] Moving a file from one location to another

On Wed, Oct 17, 2012 at 12:53 PM, Rui Barradas <[email protected]> wrote:
Hello,

On Windows this should be the old DOS command RENAME (or REN) and apparently
the R function ?file.rename carries it's name.

I wasn't aware of the file.*() functions -- I'll of course retract my
statement that this has to be OS direct via system(). Thanks for that
Rui!

Cheers,
Michael

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to