2

I want to plot timeline activity graph using R.The output that I want is something like this

enter image description here

where the first line is 'Badges', second is 'comments', third is 'posts' and 4 th is 'Edits'

I have the time values stored in a txt file and the format of time 'yyyy-MM-dd hh:mm:ss' and these shows when each attribute of above 4 rows were earned.

NOTE: The 1st and 4th row are the most important.Also the yellow bar in 1st row is specific time under cosideration.

since I am new to R, so I have no idea how can I plot the time activities on graph.

UPDATE I am able to see the examples but I am still not able to implement it.I tried following

rawschedule <- read.txt("C:/date.txt", header = TRUE)

dfr <- data.frame(start.date = c(rawschedule["LastEditDate"]),end.date = c(rawschedule["LastEditDate"]))

mdfr <- melt(dfr, measure.vars = c("LastEditDate", "LastEditDate"))

ggplot(mdfr, aes(as.Date(value, "%y-%M-%d %h:%m:%s"),y='rawschedule$LastEditDate')) + geom_line(size = 6) +xlab(" ") + ylab(" ") +theme_bw()

But it throws error as Error in seq.int(0, to0 - from, by) : 'to' cannot be NA, NaN or infinite. I am not able to understand how to correct it

UPDATE: the structure of data as dput(head(dfr,10)) is

"2013-05-07 12:34:09", "2013-05-13 08:51:57", "2013-05-13 12:56:47", 
"2013-05-13 13:57:45", "2013-05-14 06:25:19", "2013-05-15 17:30:45", 
"2013-05-15 18:01:35", "2013-05-15 18:32:31", "2013-05-19 18:12:51", 
"2013-05-22 08:10:39", "2013-05-27 05:10:18", "2013-05-27 21:04:00", 
"2013-05-30 18:22:08", "2013-05-30 21:25:41", "2013-05-30 21:52:40", 
"2013-06-01 08:08:24", "2013-06-01 14:40:49", "2013-06-03 08:25:20", 
"2013-06-03 11:47:29", "2013-06-03 15:18:08", "2013-06-03 19:57:09", 
"2013-06-04 07:16:31", "2013-06-04 13:45:14", "2013-06-04 16:16:28", 
"2013-06-05 07:06:33", "2013-06-05 07:14:08", "2013-06-05 10:02:25", 
"2013-06-05 14:18:12", "2013-06-05 18:55:47", "2013-06-06 10:26:43", 
"2013-06-06 11:50:31", "2013-06-06 15:13:30", "2013-06-06 15:19:58", 
"2013-06-06 19:17:00", "2013-06-09 17:08:41", "2013-06-10 10:19:56", 
"2013-06-10 14:22:22", "2013-06-10 16:40:15", "2013-06-11 21:50:14", 
"2013-06-12 08:47:17", "2013-06-13 14:47:20", "2013-06-13 15:10:30", 
"2013-06-13 15:51:57", "2013-06-15 14:32:19", "2013-06-16 11:19:34", 
"2013-06-16 21:17:41", "2013-06-17 08:23:25", "2013-06-18 21:36:17", 
"2013-06-18 21:36:23", "2013-06-19 08:06:51", "2013-06-19 10:16:00", 
"2013-06-19 14:47:56", "2013-06-19 15:20:33", "2013-06-19 17:10:53", 
"2013-06-19 17:10:55", "2013-06-19 18:35:57", "2013-06-20 13:36:20", 
"2013-06-20 14:13:17", "2013-06-21 10:09:07", "2013-06-21 14:43:51", 
"2013-06-23 14:10:38", "2013-06-23 14:38:47", "2013-06-24 15:58:20", 
"2013-06-25 16:30:57", "2013-06-26 08:03:29", "2013-06-26 08:06:51", 
"2013-06-26 09:20:36", "2013-06-26 15:48:17", "2013-06-26 15:49:09", 
"2013-06-26 15:49:21", "2013-06-26 16:30:52", "2013-06-26 16:30:56", 
"2013-06-26 16:59:34", "2013-06-26 19:09:56", "2013-06-27 08:38:05", 
"2013-06-27 09:28:56", "2013-06-27 09:29:59", "2013-06-27 10:25:51", 
"2013-06-28 20:23:10", "2013-06-30 16:18:48", "2013-07-01 10:45:08", 
"2013-07-09 08:58:46", "2013-07-11 20:57:33", "2013-07-13 11:58:12", 
"2013-07-17 10:59:50", "2013-07-18 12:17:40", "2013-08-08 09:38:52", 
"2013-08-09 14:22:06", "2013-08-26 15:23:55", "2013-08-27 13:59:13", 
"2013-08-30 12:21:23", "2013-09-17 12:49:05", "2013-10-03 16:01:29"
user2916886
  • 847
  • 2
  • 16
  • 35
  • See `gantt.chart` in the plotrix package. – G. Grothendieck Dec 01 '13 at 21:46
  • @G.Grothendieck I saw `gantt.chart` and I also saw few examples of it but I was unable to understand and implement it in my case.If you could help in implementation it will be appreciated.Thanks!! – user2916886 Dec 01 '13 at 21:53
  • Try `example(gantt.chart)` and follow those examples. – G. Grothendieck Dec 01 '13 at 22:04
  • it seems `example(gantt.chart)` is not a valid command.It throws warning error as "In example(gantt.chart) : no help found for ‘gantt.chart’" – user2916886 Dec 01 '13 at 22:13
  • Be sure you have issued `library(plotrix)` first. It can also be found at the bottom of `?gantt.chart` and also at the bottom of this page: http://www.inside-r.org/packages/cran/plotrix/docs/gantt.chart – G. Grothendieck Dec 02 '13 at 00:00
  • @G.Grothendieck I checked few examples and based on that I tried something.It is posted below.Can you help in correcting it? – user2916886 Dec 02 '13 at 00:33
  • Can you provide some actual data? Use `dput(head(dfr, 10))` or something similar so you get a nice mix of the data. – Tyler Rinker Dec 02 '13 at 02:38
  • @TylerRinker I have updated the below post with output of `dput(head(dfr, 10))` – user2916886 Dec 02 '13 at 03:07
  • possible duplicate of [Gantt style time line plot (in base R)](http://stackoverflow.com/questions/9862519/gantt-style-time-line-plot-in-base-r) – Tyler Rinker Dec 02 '13 at 03:14
  • @TylerRinker there is a difference between my question and the post you mentioned.The post mentioned is concerned about how to make an exact gantt chart while my requirement is not exactly of gantt chart but gantt chart is the only solution I am able to think of right now.I have to plot a specific time on graph and not an interval and that too from a txt file – user2916886 Dec 02 '13 at 04:20
  • @BlueMagister I have made the changes in my original post and have deleted the post below – user2916886 Dec 02 '13 at 04:22
  • Seems to me to be a 1 second interval. The data appears to be one vector. How do you know what type of activity the time is at. Plus this isn't a true dput. You only posted part of what was in the console. – Tyler Rinker Dec 02 '13 at 05:25

1 Answers1

1

I'm the author of the original paper in which this visualization was found. Another researcher emailed me and asked if I'd release the code; you can now find a version here that is available for anyone to use:

https://github.com/scotchfield/behaviour_plot

(Note that this is not an R response, just a note for where the original tool can be found for reference.)

swrittenb
  • 326
  • 2
  • 13
  • Thanks @swrittenb for the note! Just a quick question.I saw the behaviour.py file. Is the pygame lib the main point behind the visualizations? – user2966197 Jun 11 '14 at 23:51
  • pygame is strictly used for drawing images to the screen. In the original study, we needed to jump around between different events and users quickly, so it had to be interactive instead of just rendering to an image. If pygame is causing issues with installs, I'm happy to try to swap it out for a different graphics lib. – swrittenb Jun 12 '14 at 15:26