I'm trying to plot the attached data in R using ggplot.
Here's my script:
library(ggplot2)dat<-read.csv("dat.csv",header=TRUE,sep=",")dat<-data.frame(dat)dat$min<-dat$zam-sd(dat$zam)dat$max<-dat$zam+sd(dat$zam)ggplot(dat,aes(dd,zam))+geom_ribbon(aes(ymin=min,ymax=max),fill="skyblue")+geom_line(color="steelblue4",lwd=1)+theme(panel.background=element_rect(fill="white"), axis.line=element_line(colour="black"), panel.border = element_rect(colour = "black", fill=NA, size=5))
Question:
I would like the xaxis to be in months (January to December). But the data is for a leap year. I tried this command by gave an error.
dat$date <- seq(as.Date("2012/1/1"), as.Date("2012/12/31"), "month")
Error:
Error in
$<-.data.frame
(*tmp*
, "date", value = c(15340, 15371, 15400, : replacement has 12 rows, data has 366
Can anyone suggest a simple method to do this.