r - Plot monthly and annual mean on a single plot -


i want plot monthly , annual temperature. based on examples on forum have assembled monthly annual data. however, aggregation created data sorted month , year. how plot data beginning january 1995 in r base plot or ggplot?

tt<- rnorm(4018, 5, 8) date<-seq(as.date('1995-01-01'),as.date('2005-12-31'),by = 1) df<-data.frame(date,tt) df$month <- months(df$date) df$year <- format(df$date,format="%y") df1<-aggregate(tt ~ month + year , df , mean) 

in base r can following:

tt<- rnorm(4018, 5, 8) date<-seq(as.date('1995-01-01'),as.date('2005-12-31'),by = 1) df<-data.frame(date,tt) df$month <- months(df$date) df$year <- format(df$date,format="%y") df1<-aggregate(tt ~ month + year , df , mean)  #make date column df1$date <- as.date(paste('01', df1$month, df1$year), format='%d %b %y')  #plot tt on dates made above plot(df1$date, df1$tt) 

enter image description here


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -