ggvis:关于因子水平的点数的加入

时间:2014-12-03 18:14:17

标签: r plot ggvis

我想将一个变量的值与其他变量的值相关联。在我的示例中,我想要将Y的值与XFactor的值相关联。特别是Y=20X=1的{​​{1}}应与Factor=AY=9的{​​{1}}相关联,而不是与X=2 Factor=A相关联}和Y=15等等。

X=1

enter image description here

1 个答案:

答案 0 :(得分:1)

如果我理解您想要正确执行的操作,只需按正确的顺序对数据进行排序即可。

library(dplyr)
library(ggvis)
ggvis(data=df, x= ~Y, y= ~X, fill= ~Factor, stroke = ~Factor) %>% 
  arrange(X) %>%
  group_by(Factor) %>%
  layer_points(shape=~Factor) %>% 
  layer_paths(fill := NA)  %>%
  scale_numeric('y', reverse=TRUE)

enter image description here