user7928323
user7928323

Reputation: 21

r time interval plot

time                count

2017-03-08 19:33    1

2017-03-23 22:11    1

2017-03-30 3:30     10

2017-03-09 19:33    13

2017-03-23 22:11    1

2017-03-31 3:30     1

.....

this data is about how fast consumers comments write

so I want to make a plot which I can easily know about how fast comments on.

For example,

In X axis, time series starts from 2017-03-08

through same interval(seconds or minute) there is a bar plot

so if the comments write speed is fast, the bar plot is dense.

and then time goes on, spped is not that fast, the bar plot is not dense

how can I make it?

 cc5<-dt[, tdiff := difftime(cc, shift(cc, fill=cc[1L]), units="secs"), 
 by=title]

using this code, I can make difftime column

I have one more problem time column is character type

so I try to change it to date type using as.Date it doesn't work

so I change it to POSIXct type

I think to make X axis in time series I need to change date type

Upvotes: 0

Views: 500

Answers (1)

Kim
Kim

Reputation: 4288

I'm not 100% sure that I'm really understanding the result that you want, but generally when I want to put dates in the x-axis, I go to Understanding dates and plotting a histogram with ggplot2 in R and use Gauden's Code v1. If you have successfully changed the character into a POSIXct time, as.Date() should work fine.

Upvotes: 1

Related Questions