[R-SIG-Finance] xts library Can I put my test data into the R code ( without reading a file ) ?

Pierre8r pierre8r-gmane at yahoo.fr
Mon Jul 14 12:29:14 CEST 2008


Hello,


I want to work with some test datas like that ones :

2007-12-03  100.00  110.00  90.00  110.00
2007-12-04  110.00  120.00 100.00  120.00
2007-12-05  120.00  130.00 110.00  130.00
2007-12-06  130.00  140.00 120.00  140.00


I know I can create a CSV file and use this kind of R code :


library(xts)
library(quantmod)
quotes <-
read.csv2("E:\\00001-Compare\\Output\\OutputJBacktesting\\Quotes1HOUR.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('Open','High','Low','Close','Volume')

It works, but I like to know if I could do the job a other way.
Something like that :

library(xts)

x <- xts(
2007-12-03  100.00  110.00  90.00  110.00
2007-12-04  110.00  120.00 100.00  120.00
2007-12-05  120.00  130.00 110.00  130.00
2007-12-06  130.00  140.00 120.00  140.00
)

x

Can I put my test data into the R code ( without reading a file ).


Thanks,

Pierre8r



More information about the R-SIG-Finance mailing list