On Mar 4, 2012, at 4:51 AM, Ajay Askoolum wrote:
I know how to do this when creating the time series variable in one
expression, e.g.
valuesTS1-ts(values,start=2000); # Frequency naturally defaults to 1
How can I specify the frequency of a time series?
I do not see a `frequency-` usage illustrated on the ?frequency page,
but the method of specifying frequency on the ?ts page does seem
fairly obvious.
It wasn't obvious to me whether ts() could gracefully coerce an
existing ts-object if only offered the object and a new frequency
parameter. Testing, however, shows that such coercion does not result
in keeping the original start parameter. Efforts to alter only the
third tsp() attribute likewise failed for me.
Using the example on the ?ts page in the absece of the requested
reproducible code. it looks like the effective procedure is to recover
the start parameter and offer an altered frequency parameter:
test.ts - ts(1:10, frequency = 4, start = c(1959, 2)) # 2nd
Quarter of 1959
test.ts - ts(test.ts, frequency = 8)
test.ts
Time Series:
Start = c(1, 1)
End = c(2, 2)
Frequency = 8
[1] 1 2 3 4 5 6 7 8 9 10
# Note that the start parameter was removed
# This seems to work.
test.ts - ts(1:10, frequency = 4, start = c(1959, 2)) # 2nd
Quarter of 1959
ts(test.ts, start=start(test.ts), frequency=12)
Feb Mar Apr May Jun Jul Aug Sep Oct Nov
1959 1 2 3 4 5 6 7 8 9 10
--
values=c(12,34,65,12);
values-ts(values);
frequency(values);
[1] 1
start(values)
[1] 1 1
frequency(values)-12;
Error in frequency(values) - 12 : could not find function
frequency-
[[alternative HTML version deleted]]
__
R-help@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.
David Winsemius, MD
West Hartford, CT
__
R-help@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.