I wanted to plot time series data in R by using ggplot but I have faced with this error:
Error in continuous_scale(aesthetics, "date", identity, breaks = breaks, :
unused argument(s) (format = "%b-%Y")
Syntax:
ggplot(p29, aes(dt, ambtemp)) + geom_line() +
scale_x_date(format = "%b-%Y") + xlab("") + ylab("Tempreture")
File Name: p29
ambtemp dt surtemp
1 -1.14 2007-09-29 00:01:57 -2.712
2 -1.12 2007-09-29 00:03:57 -2.775
3 -1.33 2007-09-29 00:05:57 -2.712
4 -1.44 2007-09-29 00:07:57 -2.837
5 -1.54 2007-09-29 00:09:57 -2.775
6 -1.29 2007-09-29 00:11:57 -2.900
In function
scale_x_date()you should writelabels=date_format("%b-%Y"). Also columndtshould be formatted asDate.To show hours and minutes, instead of function
scale_x_date()you should usescale_x_datetime()and writelabels=date_format("%H:%M"). To control breaks argumentbreaks=date_breaks()is used. Also columndtshould be formatted asPOSIXt.