0

I know we can create Gantt Charts in R, but I would like to be able to create a table that contains some 5-7 rows of data and then a Gantt chart to the right.

df <- structure(list(Position = structure(c(1L, 1L, 1L, 2L, 2L, 2L), .Label = c("President", 
                                                                            "Vice"), class = "factor"), Name = structure(c(4L, 1L, 3L, 1L, 
                                                                                                                           3L, 2L), .Label = c("Adams", "Burr", "Jefferson", "Washington"
                                                                                                                           ), class = "factor"), correct = c(TRUE, TRUE, TRUE, TRUE, TRUE, 
                                                                                                                                                              TRUE), win = c(FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), start = structure(c(-66021, 
                                                                                                                                                                                                                                            -63153, -61693, -66021, -63153, -61693), class = "Date"), end = structure(c(-63153, 
                                                                                                                                                                                                                                                                                                                        -61693, -58771, -63153, -61693, -58771), class = "Date")), .Names = c("Position", 
                                                                                                                                                                                                                                                                                                                                                                                              "Name", "position", "win", "start", "end"), class = "data.frame", row.names = c(NA, 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                              -6L))
df

  Position       Name   correct   win      start        end
1 President Washington     TRUE FALSE 1789-03-29 1797-02-03
2 President      Adams     TRUE FALSE 1797-02-03 1801-02-03
3 President  Jefferson     TRUE FALSE 1801-02-03 1809-02-03
4      Vice      Adams     TRUE FALSE 1789-03-29 1797-02-03
5      Vice  Jefferson     TRUE FALSE 1797-02-03 1801-02-03
6      Vice       Burr     TRUE FALSE 1801-02-03 1809-02-03

So I would want to have Position, Name, correct & win as columns in a table, and then to the right, the bars showing the timelines. How would I go about creating these in R?

Community
  • 1
  • 1
Amit Kohli
  • 2,860
  • 2
  • 24
  • 44
  • What sort of output are you hoping for? A PDF document? Just one big image? If you already know how to plot a Gantt chart, and presumably you know (or can search for) how to stick two plots side-by-side, then the only question remaining is how to display the table in the plotting device. Which suggests a duplicate of [Plot a data frame as a table](http://stackoverflow.com/q/30794273/903061). – Gregor Thomas Sep 16 '16 at 22:48
  • I was looking for an html file, something that could have mouse-over interactions. – Amit Kohli Sep 19 '16 at 15:48
  • Then use `knitr`. – Gregor Thomas Sep 19 '16 at 15:56
  • I'm sorry... so what packages would I use with knitr? Are you recommending I plot a table and a gantt chart next to eachother and knit that? – Amit Kohli Sep 21 '16 at 15:15
  • That would be my suggestion if you didn't want mouse-over interactions. Regardless, you're not going to find a "Gantt chart with table next to it" package, but you'll find plenty of options for drawing tables and for plotting Gantt charts - you just need to find a way to get a table like you want and a Gantt chart like you want and then worry about sticking them side by side - possibly in a `knitr` document. I'd recommend looking at `plotly` or something like it for creating things with mouseover interactions. – Gregor Thomas Sep 21 '16 at 16:07
  • 1
    If you want the table and the gantt chart linked via the mouseovers then you'll probably have to roll your own D3 visualization unless you can find a ready-made example that you can hack. – Gregor Thomas Sep 21 '16 at 16:09

0 Answers0