r shiny ggvis

R ggvis y brillante: layer_model_predictions(model="lm") Error... intento de replicar un objeto de tipo ''cierre''



shiny (0)

Traté de usar ggvis con brillante, pero obtuve algún error con mi muestra de prueba. Los códigos están al final de este mensaje.

Recibí el siguiente mensaje de error solo cuando traté de ejecutar ggvis con brillo:

Guessing formula = mpg ~ wt Error in rep(col, length.out = nrow(data)) : attempt to replicate an object of type ''closure''

Si comento la línea en server.R

layer_model_predictions(model = "lm") %>%

No recibiré el mensaje de error y la aplicación brillante funciona bien, excepto que no obtengo las líneas de ajuste lineales. La parte ggvis de los códigos también funciona bien cuando no se usa con brillante. Supongo que tiene algo que ver con los datos reactivos establecidos por brillante, pero no tengo ni idea de encontrar una solución rápida.

¿Cualquier sugerencia?

¡Muchas gracias por la ayuda!

Ying

ui.R

library(ggvis) shinyUI(pageWithSidebar( div(), sidebarPanel( sliderInput("n", "Number of points", min = 1, max = nrow(mtcars), value = 10, step = 1) ), mainPanel( ggvisOutput("plot"), tableOutput("mtc_table") ) ))

servidor.R

library(shiny) library(ggvis) library(dplyr) shinyServer(function(input, output, session) { mtc <- reactive({ mtc <- mtcars[1:input$n, ] mutate(mtc, carname=rownames(mtc), id = 1:nrow(mtc)) }) all_values <- function(x) { if(is.null(x)) return(NULL) row <- mtc()[mtc()$id == x$id, ] row$carname } mtc %>% ggvis(x= ~wt, y= ~mpg, key := ~id, fill = ~factor(cyl)) %>% layer_points() %>% group_by(cyl) %>% add_tooltip(all_values,"hover") %>% layer_model_predictions(model = "lm") %>% bind_shiny("plot") output$mtc_table <- renderTable({ mtc()[, c("carname", "wt", "mpg", "cyl")] }) })