【发布时间】:2015-07-14 13:19:09
【问题描述】:
我想用 ggvis 显示多行。
数据
df <- read.table(header = TRUE, text = "
subfunctionname activityname label activityunits activityhours ftehours avFteHours wlFteHours
North IncidentPriority0 01-Jan 3950 3 36244 18122 11850
North IncidentPriority0 02-Feb 0 3 32800 16400 0
North IncidentPriority0 03-Mar 0 3 36408 18204 0
North IncidentPriority0 04-Apr 0 3 35096 17548 0
North IncidentPriority0 05-May 0 3 36244 18122 0
North IncidentPriority0 06-Jun 0 3 35260 17630 0
North IncidentPriority0 07-Jul 0 3 36285 18142.5 0
North IncidentPriority0 08-Aug 0 3 36326 18163 0
North IncidentPriority0 09-Sep 0 3 35137 17568.5 0
North IncidentPriority0 10-Oct 0 3 36203 18101.5 0
North IncidentPriority0 11-Nov 3721 3 35260 17630 11163
North IncidentPriority0 12-Dec 3947 3 36285 18142.5 11841
")
代码
library(ggvis)
df %>%
ggvis( ~label, ~avFteHours) %>% layer_lines() %>%
layer_lines( ~label, ~wlFteHours, stroke:="blue") %>%
layer_lines( ~label, ~ftehours, stroke:="red")
结果令人满意,但我无法添加图例,也无法以某种方式标记三行。
如果我使用add_legend,我会得到一个错误:
df %>%
ggvis( ~label, ~avFteHours) %>% layer_lines() %>%
layer_lines( ~label, ~wlFteHours, stroke:="blue") %>%
layer_lines( ~label, ~ftehours, stroke:="red") %>%
add_legend()
Error: length(scales_props) not greater than 0
【问题讨论】:
-
我想知道您是否设法制作了您想要的人物。如果您需要任何其他帮助,请告诉我。