[R] getting a timeseries element into a string

David Winsemius dwinsemius at comcast.net
Sun Jul 12 19:50:15 CEST 2009


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




More information about the R-help mailing list