Disappearing values in ggvis when using tooltip on grouped data

后端 未结 2 369
臣服心动
臣服心动 2021-01-23 05:14

This works fine

library(dplyr)
library(ggvis)

years <- as.factor(c(2013,2013,2014,2014,2015,2015))
months <- c(1,2,1,2,1,2)
values <- c(3,2,4,6,5,1)

d         


        
2条回答
  •  误落风尘
    2021-01-23 05:48

    The problem lies in you putting group_by before ggvis and calling add_tooltip afterwards. Just put group_by part after ggvis call

    df %>% 
      ggvis(~months, ~values, key:= ~id) %>% 
      group_by(years) %>%
      layer_points( fill = ~years) %>%
      add_tooltip(all_values, "hover")
    

    no idea why it happens though

提交回复
热议问题