r - ggvis tooltip with layer_paths -


this simple example of data:

df1 <- structure(   list(     x = c(1250, 2500, 3750, 5000, 6250, 7500, 8750,           10000), y = c(             0.112151039933887, 0.0792717402389768, 0.064716676038453,             0.0560426379617912, 0.0501241024200681, 0.0457556453076907, 0.0423607088430516,             0.0396242625334144           )   ), .names = c("x", "y"), row.names = c(na,-8l), class = "data.frame" ) 

i want create smooth line tooltip shows values x , y. i'm doing right now

library(ggvis) library(dplyr) all_values <- function(x)  {   if(is.null(x)) return(null)   row <- smoothed[smoothed$id == x$id, ]   paste0(names(row), ": ", format(row), collapse = "<br />") } smoothed <- df1 %>% compute_smooth(y ~ x) %>% rename(x=pred_ , y=resp_) smoothed$id <- 1:nrow(smoothed) smoothed %>% ggvis(~x, ~y, key:= ~id, stroke := "red", strokewidth := 5) %>% layer_paths() %>%   add_tooltip(all_values, "hover") 

the tooltip showing same values.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -