How to display pageviews over time using qplot?

I uploaded log to dataframe v . You can see the result of head(v) :

  user_id page_id timestamp 1 139 1612783 2011-02-22 06:24:40 2 139 1612783 2011-02-22 06:28:40 3 139 1612783 2011-02-22 06:41:01 

How can i qplot specify qplot per day?

  • On the x axis, this will be the day (e.g. 2011-02-22 ).
  • On the y axis, this will be the page_id number for that particular date.
+4
source share
2 answers

This will work:

 v <- data.frame( timestamp = as.Date(c("2011-02-22", "2011-02-22", "2011-02-23")), page_id = c(1,2,1)) newdata <- data.frame(time=names(new), count=new) qplot(time, page, data = newdata) 

It is worth reading the ggplot manual, which has many qplot examples, including time series.

+2
source
 t1 = with(v, table(as.Date(timestamp), page_id)) t2 = apply(t1 > 0, 1, sum) dates = as.Date(names(t2)) plot(t2 ~ dates) # using plot qplot(dates, t2, data=data.frame(t2, dates)) # using qplot 

You can write this in a more compact form, but in this way you can check the values โ€‹โ€‹of t1 and t2 .

+1
source

Source: https://habr.com/ru/post/1345382/


All Articles