[R-SIG-Finance] xts library Can I put my test data into the R code ( without reading a file ) ?
Gabor Grothendieck
ggrothendieck at gmail.com
Mon Jul 14 13:57:57 CEST 2008
Try this:
library(xts) # this also pulls in zoo
Lines <- "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 <- read.zoo(textConnection(Lines))
x <- as.xts(x)
On Mon, Jul 14, 2008 at 6:29 AM, Pierre8r <pierre8r-gmane at yahoo.fr> wrote:
> 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
>
> _______________________________________________
> 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