1. # Regression Plots using rCharts
  2. require(ggplot2)
  3. require(rCharts)
  4. dat = fortify(lm(mpg ~ wt, data = mtcars))
  5. names(dat) = gsub('\\.', '_', names(dat))
  6. p1 <- rPlot(mpg ~ wt, data = dat, type = 'point')
  7. p1$layer(y = '_fitted', copy_layer = T, type = 'line',
  8. color = list(const = 'red'),
  9. tooltip = "function(item){return item._fitted}")
  10. p1