[R] R problem: unable to read data in the xls-format in the PerformAnalytics package

Joshua Ulrich josh.m.ulrich at gmail.com
Wed Jan 11 16:10:04 CET 2012


On Wed, Jan 11, 2012 at 2:41 AM, yseiler at bluewin.ch <yseiler at bluewin.ch> wrote:
> Hallo
>
> I have the following problem
>
> 1) Problem: I am unable to read data in the xls-format in the PerformAnalytics
> package.
> While it works well for several commands, e.g.
> t(table.Stats(msci_ret))
>
> it does not work for other
> commands, e.g.
> x
> <- msci_ret[, c("CH"), drop = FALSE]
> table.Drawdowns(x)
>
> The error code is:
> Error in checkData(R) :
>
> The data cannot be
> converted into a time series.  If you are trying to pass in names from a data object with one
> column, you should use the form 'data[rows, columns, drop = FALSE]'.  Rownames should have standard date formats, such
> as '1985-03-15'.
>>
>
>
> 2) I guess it is the German data format after I transform the data from ts --> xls.
> Jan 1970
> -0.025317808
> -0.0488751680 -0.006219300 -0.0737541890 -0.015215166 Feb 1970 -0.016650677 -0.0289782710 -0.053743041
> 0.0548771330
> 0.012912517
> Mrz 1970 -0.000312907  0.0094675260  0.025474411  0.0060957210  0.040465110 ...
> Okt 2010
> 0.029227924
> 0.0572494500  0.024199223  0.0386233850 -0.016248884 Nov 2010 -0.023411677  0.0133836160 -0.024089614
> 0.0011141310
> 0.060007812
> Dez 2010  0.019613741  0.0375536810  0.065130745  0.0647369970  0.041147678
>
> ... but I am not
> sure, perhaps
> it is something else.
>
> 3) What I did: I save excel-data (6 raw time series with a header line) in the csv-
> format and read it in R, first in ts, and then converting it to csv:
> msci_ret = ts(msci_ret, start=1970, frequency=12)
> msci_ret <-
> as.xts(msci_ret)
>
Please provide a reproducible example (your file was not attached).
Use dput() to include a _small_ sample of your data.  My guess is that
Excel is not saving the dates to the CSV in a standard date format.

> Apparently, I do not understand exactly how to generate a date format for monthly data
> which can be read unter PerformanceAnalytics.
> I attach my csv data.
> Thanks for your help!
> yvonne

Best,
--
Joshua Ulrich  |  FOSS Trading: www.fosstrading.com



More information about the R-help mailing list