I made a dataframe with columns year,month,temp,upper and lower
upper and lower are the max temperature by year and lower is the minimum
I have two questions:
first is why for some values in the end of dataframe the upper and lower are not correctly computed but in the rest of the dataframe they are fine?
And why am I getting weird axes when I am using ggplot the dataframe is this
as you can see upper and lower for 2017 is wrong
Year Month Temp upper lower
1 1880 Jan -.29 -.29 -.09
2 1880 Feb -.18 -.29 -.09
3 1880 Mar -.11 -.29 -.09
......
1655 2017 Nov .84 .96 1.12
1656 2017 Dec .88 .96 1.12
the code is:
newDF <- df %>%
group_by(Year) %>%
mutate(upper = max(Temp), # identify max value for month day
lower = min(Temp) # identify min value for month day
) %>%
ungroup()
p <- ggplot(newDF, aes(Month, Temp)) +
geom_linerange(newDF, mapping=aes(x=Year, ymin=lower, ymax=upper), colour = "wheat2", alpha=.1)
print(p)