[R-SIG-Finance] How to merge Date and Time in a single value ?
Jeff Ryan
jeff.a.ryan at gmail.com
Tue Jun 17 19:19:30 CEST 2008
Or you can use zoo/xts (substitute zoo() for xts()):
library(xts)
library(quantmod)
quotes <- read.csv2("GBPUSD-30mn.txt", header = TRUE, sep = ",", dec=".")
x <- xts(as.matrix(quotes[,-(1:2)]),as.POSIXct(paste(quotes[,1],quotes[,2]),format='%m/%d/%Y
%H:%M'))
colnames(x) <- c('Open','High','Low','Close','Volume')
barChart(x,TA=NULL)
Jeff
On Tue, Jun 17, 2008 at 11:47 AM, <pierre8r-list at yahoo.fr> wrote:
> Hello,
>
> I am a newbie with R.
> I try to import stock quotes in R.
>
> Samples stock quotes :
>
> date ,time ,open ,high ,low ,close ,volume
> 12/29/2006,00:00,1.963,1.963,1.96195,1.96195,-1
> 12/29/2006,00:30,1.96195,1.9624,1.96195,1.962,-1
> 12/29/2006,01:00,1.962,1.9622,1.9608,1.961,-1
> 12/29/2006,01:30,1.961,1.9619,1.96095,1.96105,-1
> 12/29/2006,02:00,1.96105,1.96185,1.96105,1.9617,-1
> 12/29/2006,02:30,1.9617,1.9624,1.9616,1.9621,-1
> 12/29/2006,03:00,1.9621,1.96215,1.96155,1.96175,-1
> 12/29/2006,03:30,1.96175,1.96205,1.9615,1.96205,-1
> 12/29/2006,04:00,1.96205,1.9626,1.962,1.96235,-1
> 12/29/2006,04:30,1.96235,1.96305,1.96215,1.96275,-1
> 12/29/2006,05:00,1.96275,1.96345,1.96245,1.96325,-1
> 12/29/2006,05:30,1.96325,1.9639,1.96325,1.96375,-1
> 12/29/2006,06:00,1.96375,1.9647,1.9637,1.9646,-1
> 12/29/2006,06:30,1.9646,1.9657,1.964,1.964,-1
> 12/29/2006,07:00,1.964,1.96535,1.96385,1.9651,-1
>
>
> I wrote a few lines of R.
>
> Code:
>
> quotes <- read.csv2("GBPUSD-30mn.txt", header = TRUE, sep = ",", dec=".")
> quotes
> names(quotes)
>
>
> The result does not agree me.
> I would like to have the date and time data in a single value.
> The goal is then to display these stock prices as a graph.
>
> Regards,
>
> Pierre8r
>
>
> ____________________________________________________
> intelligente 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.
>
--
Jeffrey Ryan
jeffrey.ryan at insightalgo.com
ia: insight algorithmics
www.insightalgo.com
More information about the R-SIG-Finance
mailing list