[R] getting a timeseries element into a string
spencerg
spencer.graves at prodsyse.com
Wed Jul 15 02:29:15 CEST 2009
Hello:
1. I tried the example. The first thing I noticed was that
"library(fSeries)" loaded with the following comment:
# The new version of 'fSeries' has been renamed to 'timeSeries'
2. With this, I tried "library(timeSeries)". Then your first
example worked without error.
3. This time, "head(ts)" generated an error. To diagnose it, I
tried "str(ts)". This generated a summary that I found beautifully
formated but unintelligible. To understand the object, I then tried
"utils:::str.default(ts)". This described the object in terms I could
understand.
4. Another "heads up": "ts" is the name of a function in the
"stats" package. I would avoid creating an object by that name.
Hope this helps.
Spencer
David Winsemius wrote:
>
> On Jul 12, 2009, at 1:05 PM, David Winsemius wrote:
>
>>
>> On Jul 12, 2009, at 8:10 AM, tradenet wrote:
>>
>>>
>>> I added a reproducible example to my question...
>>>
>>> ts<-dummyDailySeries(x = rnorm(365), units = NULL, zone = "",
>>> FinCenter =
>>> "")
>>
>>
>> "Heads up" is an English colloquial warning.
>>
>> It may be reproducible on a machine that has all of your particular
>> loaded packages, but certainly not on one that doesn't.
>>
>> ts<-dummyDailySeries(x = rnorm(365), units = NULL, zone = "",
>> FinCenter =
>> + "")
>> Error: could not find function "dummyDailySeries"
>>
>> Many people who read the list just ignore postings where the
>> questioner fails to indicate the package from which functions arise.
>>>
>>
>
> In penance for my failure to trim the r-help list address, I looked up
> the function which is part of the fSeries package. I now wonder if
> tradenet is using an outdated version. I get a different error after
> installing and loading Package fSeries (270.76.1).
>
> > ts<-dummyDailySeries(x = rnorm(365), units = NULL, zone = "",
> FinCenter =
> + "")
> Error in rulesFinCenter(FinCenter) :
> There are no DST rules for GMT FinCenter!
>
> Eventually I convince the function into returning a result and then
> ts[1,0] fails with this error message:
> > ts<-dummyDailySeries(x = rnorm(365), units = NULL, zone = "GMT",
> FinCenter = "Zurich")
> > head(ts)
> TS.1
> 1970-01-01 01:00:00 -0.2463952
> 1970-01-02 01:00:00 0.9421668
> 1970-01-03 01:00:00 0.3354345
> 1970-01-04 01:00:00 1.7449670
> 1970-01-05 01:00:00 0.1551346
> 1970-01-06 01:00:00 -1.0082531
> > ts[1,0]
> Error in checkSlotAssignment(object, name, value) :
> assignment of an object of class "NULL" is not valid for slot
> "units" in an object of class "timeSeries"; is(value, "character") is
> not TRUE
>
> So now I am wondering if the package was recently redesigned to use S4
> methods. My suggestion is to repost if you are still puzzled after
> updating your copy of fSeriesand reviewing the timeSeries extractor
> functions for S4 objects including seriesPositions():
> X = timeSeries(matrix(rnorm(24), 12), timeCalendar())
> as.character(seriesPositions(X)@Data[1])
> [1] "2009-01-01" # a character vector ... which is what was requested
>
>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list