Displaying 3 results from an estimated 3 matches for "scale_x_yearqtr".
2018 Jan 28
0
Plotting quarterly time series
...quot;,
"Q2 1962", "Q3 1962", "Q4 1962")
## convert to zoo series
library("zoo")
z <- zoo(as.matrix(d[, 1:2]), as.yearqtr(d$time, "Q%q %Y"))
## ggplot2 display
library("ggplot2")
autoplot(z)
## with nicer axis scaling
autoplot(z) + scale_x_yearqtr()
## some variations
autoplot(z, facets = Series ~ .) + scale_x_yearqtr() + geom_point()
autoplot(z, facets = NULL) + scale_x_yearqtr() + geom_point()
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.e...
2018 Jan 28
2
Plotting quarterly time series
I have a data set with quarterly time series for several variables. The
time index is recorded in column 1 of the dataframe as a character vector
"Q1 1961", "Q2 1961","Q3 1961", "Q4 1961", "Q1 1962", etc. I want to
produce line plots with ggplot2, but it seems I need to convert the time
index from character to date class. Is that right? If so, how
2018 Jan 28
1
Plotting quarterly time series
..."Q4 1962")
>
> ## convert to zoo series
> library("zoo")
> z <- zoo(as.matrix(d[, 1:2]), as.yearqtr(d$time, "Q%q %Y"))
>
> ## ggplot2 display
> library("ggplot2")
> autoplot(z)
>
> ## with nicer axis scaling
> autoplot(z) + scale_x_yearqtr()
>
> ## some variations
> autoplot(z, facets = Series ~ .) + scale_x_yearqtr() + geom_point()
> autoplot(z, facets = NULL) + scale_x_yearqtr() + geom_point()
>
>
>
>> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUB...