Graphics Reference
In-Depth Information
1972 49 61 NA NA
1973 68 44 40 27
1974 28 25 24 24
To convert it to a two-column data frame with one column representing the year with fractional
values, we can do the same as before:
pres_rating <- data.frame(
year = as.numeric(time(presidents)),
rating = as.numeric(presidents)
)
pres_rating
year rating
1945.00
NA
1945.25
87
1945.50
82
...
1974.25 25
1974.50 24
1974.75 24
It is also possible to store the year and quarter in separate columns, which may be useful in some
visualizations:
pres_rating2 <- data.frame(
year = as.numeric(floor(time(presidents))),
quarter = as.numeric(cycle(presidents)),
rating = as.numeric(presidents)
)
pres_rating2
year quarter rating
1945
1
NA
1945
2
87
1945
3
82
...
1974
2
25
1974
3
24
1974
4
24
See Also
The zoo package is also useful for working with time series objects.
Search WWH ::




Custom Search