[R-SIG-Finance] How to format a CSV file output ?

Josh Ulrich josh.m.ulrich at gmail.com
Wed Jul 16 17:10:34 CEST 2008


write.csv(x, file = "OutputIndic.csv", quote = FALSE, row.names =
format(index(x), "%m/%d/%Y,%H:%M:%S"))

--
http://quantemplation.blogspot.com


On Wed, Jul 16, 2008 at 9:32 AM,  <pierre8r-list at yahoo.fr> wrote:
> Hello,
>
> Here my R code :
>
> library(xts)
> library(quantmod)
>
> quotes <- read.csv2("E:\\00001-Compare\\Output\\OutputJBacktesting\\InputIndic.txt",
> header = FALSE, sep = ",", dec=".")
>
> x <- xts(as.matrix(quotes[,-1]),as.POSIXct(paste(quotes[,1]),format='%m/%d/%Y
> %H:%M'))
> colnames(x) <- c('Indic')
> x
>
> write.csv(x, file = "OutputIndic.csv", quote = FALSE, row.names = FALSE)
>
> The x give this output to the R Console :
>
>> colnames(x) <- c('Indic')
>> x
>                      Indic
> 2007-01-08 00:59:00 1.93025
> 2007-01-08 01:59:00 1.92960
> 2007-01-08 02:59:00 1.92805
>
>
> My goal is to generate this kind of CSV output :
>
> 01/08/2007,00:59, 1.93025
> 01/08/2007,01:59, 1.92955
> 01/08/2007,02:59, 1.92885
>
> My write.csv generate this CSV output :
>
> Indic
> 1.93025
> 1.9296
> 1.92805
>
> How to generate this kind of output ?
>
> 01/08/2007,00:59, 1.93025
> 01/08/2007,01:59, 1.92955
>
> Thanks,
>
> Pierre8r
>
>
>
>      ____________________________________________________________
> ente http://mail.yahoo.fr
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>



More information about the R-SIG-Finance mailing list