有关包装计划产生的甘特图的问题

时间:2015-05-28 22:57:12

标签: r gantt-chart

我希望在如何使用plan包创建甘特图时提供一些帮助。该软件包在前面的综合文章中简要提及several approaches using R; see answer 4 of 7 for plan我的可重现数据如下。

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")

使用read.gantt(),数据框对我来说很好看:

> 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

但是当我使用print(summary()时出现问题。最后两行有问题。我尝试在.csv文件中重写它们,但没有用。

> 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  

无论如何,我跑了plot(),结果显然很奇怪 enter image description here

1 个答案:

答案 0 :(得分:2)

我是名为plan的R包的作者。通常会在包issue page上提出问题,我认为这会限制受众群体,但在提出问题时会向我发送电子邮件。

在任何情况下,为甘特图构建数据的常规方法是使用名为read.gantt()的函数。要获得有关该功能的文档,请尝试

library(plan)
?read.gantt

请注意,格式有严格的规定。它必须是纯文本文件,而不是csv,当然不是xls。使用简单的文本编辑器编辑它。如果我是你,那么当你写project并告诉你列时,我会从你输出的输出开始。将其剪切/粘贴到纯文本文件中(可能名为“plan.txt”,但名称无关紧要)。然后根据read.gantt()的文档调整标题,依此类推。然后阅读并绘制它。学习格式和查看输出的最快方法可能是查看软件包附带的插图。在R中,键入

vignette("plan")

你会明白的。我在这个消息的底部放了一个小插图页面的快照。它可能很难在SO上阅读,但只需运行上面的命令并跳到第4页就可以看到它。

如果您擅长文本编辑器,这只需要几分钟的时间。但请注意,数据的格式是非常严格,因此您可能需要使用一些奇特的编辑器技巧,如移动列。

使用R命令将数据强制转换为格式是可能的,但是根据您上面所写的内容,您似乎对R很新,最好坚持准备数据的简单路径并运行标准R命令。

如果您需要更多帮助,请与我们联系。 (同样,我不会定期阅读SO,所以除非通知我后续跟进,否则我不会回复,除非你给我发电子邮件....这就是为什么最好在{上使用问题{1}}网站,当然。)

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