After a short conversation, I made it work.
. mtcars.
mtc <- mtcars
mtc$id <- 1:nrow(mtc)
lm=with(mtc,lm(mpg~wt))
df=data.frame(fit=lm$coefficients[1]+mtcars$wt*lm$coefficients[2])
df$id <- 101:132
df$wt <- mtcars$wt
, mtc - mtcars, df - . , df id, 100, mtc data.frame.
, all_values, id mtc, , all_values, id df.
, :
all_values <- function(x) {
if(x$id>100) return(NULL)
if(is.null(x)) return(NULL)
row <- mtc[mtc$id == x$id, ]
paste0(names(row), ": ", format(row), collapse = "
")
}
. add_tooltip id data.frames:
ggvis(x=~wt) %>%
layer_points(data=mtc, y = ~mpg, key := ~id) %>%
layer_paths(data=df,y= ~fit, key := ~id) %>%
add_tooltip(all_values, "hover")
, , , .

.
