I have the following data:
set.seed(12)
df <- rnorm(1260, 0.06, 0.2)
These are 5 years worth of daily returns (with 1 year = 252 working days) and what I would like to do is draw a line-chart with months on the x axis. Basically, I would have the sequence Jan:Dec repeated five times on the x-axis, with 21 days being one month.
What I did is the following:
- Create a column with months jan-dec repeated 5 times
date <- c("Jan", "Feb", "Mär", "Apr", "Mai", "Jun",
"Jul", "Aug", "Sep", "Okt", "Nov", "Dez")
date <- rep(date, 5)
- Draw graph
df %>%
ggplot(aes(x = date, y = return)) +
geom_line() +
labs(title = "Stock return Chart", y = "return", x = "date")
Unfortunately I get the following error:
Error: Aesthetics must be either length 1 or the same as the data (1260): x
Try this:
Created on 2019-05-27 by the reprex package (v0.3.0)