[R-SIG-Finance] (no subject)

Josh Ulrich josh.m.ulrich at gmail.com
Fri Dec 5 16:29:05 CET 2008


Hi Soeren,

It appears the function you used to read your data into R expected the
file to contain a header row.  You should use the equivalent of
read.csv(file, header=FALSE).

as.xts() works on data.frames that have rownames.  The default is to
convert the rownames to POSIXct.

I recommend you try:
datas <- xts(data[,-1],as.POSIXct(data[,1]))

Best,
Josh
--
http://quantemplation.blogspot.com



On Fri, Dec 5, 2008 at 7:50 AM,  <sprohl at na.uni-tuebingen.de> wrote:
> Hello Brian,
> please find attached sample of the data
> data[1:5,]
>  X2002.07.01 X0.0071
> 1  2002-07-02  0.0072
> 2  2002-07-03  0.0072
> 3  2002-07-04  0.0073
> 4  2002-07-05  0.0073
> 5  2002-07-08  0.0073
> str(data)
> 'data.frame':   1503 obs. of  2 variables:
>  $ X2002.07.01: Factor w/ 1503 levels "2002-07-02","2002-07-03",..: 1 2 3
> 4 5 6 7 8 9 10 ...
>  $ X0.0071    : num  0.0072 0.0072 0.0073 0.0073 0.0073 0.0073 0.0073
> 0.0073 0.0073 0.0074 ...
> datas<-as.xts(data)
> Fehler in as.POSIXlt.character(x, tz, ...) :
> character string is not in a standard unambiguous format
>
> How could I convert the data to xts?
> Thank in advance,
> Soeren
>
>
>
>
>
> Please attach a short sample of your data file that replicates your error.
>>
>> sprohl at na.uni-tuebingen.de wrote:
>>> Dear All,
>>> I have some problems with downloading and matching daily data
>>> of irregular frequency. I tried to apply zoo-codes to read file
>>>
>>> data<-read.zoo("C://data.txt",sep="",format="%Y %b %d")
>>> and get the following message:
>>>
>>> Fehler in scan(file, what, nmax, sep, dec, quote, skip, nlines,
>>> na.strings,  :  Zeile 31 hatte keine 2 Elemente
>>>
>>> The data has missing values. How could I properly download them as
>>> time series and match different datasets by "Date". Unfrtunately,
>>> conventional procedures do not work properly.
>>> Thanks in advance,
>>> Soeren
>>
>>
>> --
>> Brian G. Peterson
>> http://braverock.com/brian/
>> Ph: 773-459-4973
>> IM: bgpbraverock
>>
>
> _______________________________________________
> 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