0

Am trying to show a line graph for a day records that starts at 6am till 6pm. Now when i try to populate the plot using ggplot and adding annotate to display some text below the graph or with in graph am getting error as

Error: Invalid input: time_trans works with objects of class POSIXct only

here is my sample code which is used to plot

library(ggplot2)  #load ggplot
R$date_time<-strptime(x = as.character(R$stc),format = "%d/%m/%Y %H:%M")
R$Req_Date<-as.Date(R$date_time)
R_Day<-R[R$Req_Date=='0015-11-01',]
timerange=as.POSIXct(R_Day$date_time, format="%H:%M:%S")
counTime<-as.data.frame(table(timerange))
calcitime<-sum(counTime$Freq)/60
p<-ggplot(data=R_Day,aes(x=timerange,y=Rinse_Temperature))+
ggtitle("R_Temperature")+geom_line(colour="orange",size=0.5)+
p+annotate("text", x=as.numeric(as.POSIXct(R_Day$date_time, format="%H:%M:%S")),xend=as.numeric(as.POSIXct(R_Day$date_time, format="%H:%M:%S")), y=-300,yend=300, label= "Total")

any suggestion how to override this error and show text.

Thanks in advance

Pallavi
  • 313
  • 1
  • 4
  • 17
  • 1
    Can you make a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)? – Heroka Dec 17 '15 at 09:24
  • was using "0015-11-01" on purpose? should not it be 2015-11-01? – MLavoie Dec 17 '15 at 09:35
  • @MLavoie it could be 2015-11-01 when i tried converting date using POSIXT() then i got resultant as such. so i placed value as similar – Pallavi Dec 18 '15 at 05:33
  • we don't have access to object R (as R$date_time). Care to join a sample dataset? – MLavoie Dec 18 '15 at 09:16

0 Answers0