[R] Change the frequency of a ts?

Achim Zeileis Achim.Zeileis at uibk.ac.at
Sat Jul 3 14:03:41 CEST 2010


On Sat, 3 Jul 2010, Nicholas R Frazier wrote:

> I'm trying to convert a column of a table into a ts object.  The data is
> monthly, so I want the ts frequency to be 12.
>
> I did this ...
>
>> filings.ts = as.ts(Filings.100K, frequency=12)

Use the constructor function ts(), not the coercion function as.ts(). The 
latter does not have a frequency argument. See ?ts.

>> filings.ts
>
> Time Series:
> Start = 1
> End = 311
> Frequency = 1
>  [1] 246.9336 305.6789 ... ...
>
>> tsp(filings.ts)
> [1]   1 311   1
>> tsp(filings.ts) <- c(1,311,12)
> Error in attr(x, "tsp") <- value :
>  invalid time series parameters specified
>
> What am I doing wrong here?

Not reading the documentation?

c(1, 311, 12) are not valid time series properties because it would imply 
that your series as length 311 * 12 + 1, which is not the case.
Z

> I can't seem to be able to change the frequency
> from 1 to 12.  Thanks!
>
> Nick Frazier
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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