1

I am hoping for some assistance in how to create a gantt chart with the plan package. The package is mentioned briefly in the comprehensive post earlier several approaches using R; see answer 4 of 7 for plan My reproducible data is below.

dput(project)
structure(list(key. = structure(1:8, .Label = c("1,", "2,", "3,", 
"4,", "5,", "6,", "7,", "8,"), class = "factor"), description. = structure(1:8, .Label = c("recommendation1,", 
"recommendation2,", "recommendation3,", "recommendation4,", "recommendation5,", 
"recommendation6,", "recommendation7,", "recommendation8,"), class = "factor"), 
    start. = structure(1:8, .Label = c("10/1/2015,", "10/2/2015,", 
    "10/3/2015,", "10/4/2015,", "10/5/2015,", "10/6/2015,", "10/7/2015,", 
    "10/8/2015,"), class = "factor"), end. = structure(1:8, .Label = c("12/1/2015,", 
    "12/2/2015,", "12/3/2015,", "12/4/2015,", "12/5/2015,", "12/6/2015,", 
    "12/7/2015,", "12/8/2015,"), class = "factor"), done. = c(90, 
    30, 0, 0, 0, 0, 0, 0), neededby = c(0, 0, 0, 0, 0, 0, 0, 
    0)), .Names = c("key.", "description.", "start.", "end.", 
"done.", "neededby"), row.names = c(NA, -8L), class = "data.frame")

Using read.gantt(), the data frame looks fine to me:

> project
key.     description.     start.       end. done. neededby
1   1, recommendation1, 10/1/2015, 12/1/2015,    90        0
2   2, recommendation2, 10/2/2015, 12/2/2015,    30        0
3   3, recommendation3, 10/3/2015, 12/3/2015,     0        0
4   4, recommendation4, 10/4/2015, 12/4/2015,     0        0
5   5, recommendation5, 10/5/2015, 12/5/2015,     0        0
6   6, recommendation6, 10/6/2015, 12/6/2015,     0        0
7   7, recommendation7, 10/7/2015, 12/7/2015,     0        0
8   8, recommendation8, 10/8/2015, 12/8/2015,     0        0

But something is awry when I use print(summary(). The last two rows have a problem. I tried re-writing them in the .csv file, to no avail.

> print(summary(project))
key.             description.        start.          end.       done.         neededby
1,     :1   recommendation1,:1     10/1/2015,:1   12/1/2015,:1   Min.   : 0.0   Min.   :0 
2,     :1   recommendation2,:1     10/2/2015,:1   12/2/2015,:1   1st Qu.: 0.0   1st Qu.:0 
3,     :1   recommendation3,:1     10/3/2015,:1   12/3/2015,:1   Median : 0.0   Median :0 
4,     :1   recommendation4,:1     10/4/2015,:1   12/4/2015,:1   Mean   :15.0   Mean   :0 
5,     :1   recommendation5,:1     10/5/2015,:1   12/5/2015,:1   3rd Qu.: 7.5   3rd Qu.:0 
6,     :1   recommendation6,:1     10/6/2015,:1   12/6/2015,:1   Max.   :90.0   Max.   :0 
(Other):2   (Other)         :2     (Other)   :2   (Other)   :2  

In any case, I ran plot() and the result was distinctly odd.
enter image description here

Community
  • 1
  • 1
lawyeR
  • 7,488
  • 5
  • 33
  • 63

1 Answers1

2

I'm the author of the R package named plan. Normally questions are raised on the package's issue page, which I think limits the audience but has the advantage of sending me an email when a question is asked.

In any case, the normal way to construct data for a gantt chart is to use the function named read.gantt(). To get documentation on that function, try

library(plan)
?read.gantt

Note that there are strict rules on the format. It must be a plain text file, not csv and certainly not xls. Edit it with a simple text editor. If I were you, I'd start with the output you put above when you wrote project and it told you the columns. Cut/paste that into a plain text file (named "plan.txt" perhaps, but the name does not matter). Then adjust the headings, and so forth, according to the documentation for read.gantt(). Then just read it and plot it. Probably the fastest way to learn the format and see the output would be to look in the vignette that comes with the package. In R, type

vignette("plan")

and you'll get that. I've put at the bottom of this message a snapshot of one of the pages of the vignette. It will likely be hard to read on SO but just run the command above and skip to page 4 to see it.

If you're adept in a text editor, this will only take you a few minutes to do. But note that the format for the data is very strict, so you may need to use some fancy editor tricks like moving columns.

It would be possible to coerce your data into the format using R commands, but from what you've written above it seems that you are pretty new to R, and it would be best to stick to the simpler path of preparing data and running standard R commands.

Please let me know if you need more help. (Again, I don't read SO on a regular basis, so unless SO notifies me of followups to this, I won't hear back unless you email me. ... this is why it's preferable to use an issue on the plan website, of course.)

snapshot of <code>plan</code> vignette page

dank
  • 841
  • 1
  • 8
  • 15