I have a dataframe that has precipitation (cm) for Y and days for X.
> head(precip)
Day mean
1 1 1.784654
2 2 1.850796
3 3 1.850486
4 4 1.858424
5 5 1.884435
6 6 1.907781
until 366 days (averages include leap years). Both columns are currently as numeric. This is my code for line plotting it:
precip_plots <- ggplot(data = precip, aes_string(x = "Day", y = "mean", group=1)) +
geom_line(size = 1)+
theme_bw()+
labs(title = "Daily precipitation",
x = "Day",
y = "Precipitation (cm)")
I want the days to be on the X-axis, but below (also on X-axis) I want there to be month letters (JFMAMJJASOND) for each range of the month, like
I have tried adding this to the ggplot:
scale_x_discrete(limits = 1:366, labels=Day[1:31] = "J", Day[32:60] = "F", Day[61:91] = "M",
Day[92:121] = "A", Day[122:152] = "M", Day[153:182] = "J", Day[183:213] = "J",
Day[214:244] = "A", Day[245:274] = "S", Day[275:305] = "O", Day[306:335] = "N",
Day[336:366] = "D")
but it just returns a bunch of "Error: unexpected '='" and "Error: unexpected ','".
I've looked everywhere online and on SO and I can't seem to find anyone with a similar issue.