Strange error with dplyr in Shiny app

1,256 views
Skip to first unread message

ArjunaCap

unread,
Oct 13, 2014, 5:16:50 PM10/13/14
to shiny-...@googlegroups.com
This is fine from the command line:

data <- mtcars %>% select(cyl, disp, hp)  %>% group_by(cyl) %>% summarise (disp = sum(disp), n = n())

but embedded in the following toy app, it generates a subscript out of bounds error, and seems to be generated from group_by:

server.R
library(shiny)
library(dplyr)
library(ggplot2)

data <- mtcars %>% select(cyl, disp, hp)  %>% group_by(cyl) %>% summarise (disp = sum(disp), n = n())

shinyServer(function(input, output) {

  output$table <- renderTable({
 data
  })
})
  
ui.R
shinyUI(
  fluidPage(
    fluidRow(
      tableOutput("table")
    )    
  )  
)

Any ideas of what's happening?

john crowell

unread,
Oct 13, 2014, 5:33:51 PM10/13/14
to shiny-...@googlegroups.com
Same error for me with different data, but the exact same results, and I traced it to the group_by() call. I believe a recent package update broke this since the same code was working for me about 10 days ago.

JP

unread,
Oct 14, 2014, 12:22:20 PM10/14/14
to shiny-...@googlegroups.com
I am also getting an new error with dplyr and shiny. I am only using `filter` and `%>%`.  It was not a problem a few days ago. I am getting an `Error: incorrect length(0) expecting 28255` error when I am filtering some data. 

Michael Cawthon

unread,
Oct 14, 2014, 12:42:41 PM10/14/14
to shiny-...@googlegroups.com
One clarification:  It seems related to the use of RenderTable.  Eg, renderPrint in the following code works:

data <- mtcars %>%
        select(cyl, disp, hp)  %>%
        group_by(cyl) %>%
        summarise (disp = sum(disp), n = n())   

server <- (function(input, output) {
           output$table <- renderPrint({ data })
           })

ui <- shinyUI(
      fluidPage(  verbatimTextOutput("table")  ) 
      )

shinyApp(ui = ui, server = server)


On 10/14/14, 11:22 AM, JP wrote:
I am also getting an new error with dplyr and shiny. I am only using `filter` and `%>%`.  It was not a problem a few days ago. I am getting an `Error: incorrect length(0) expecting 28255` error when I am filtering some data. 

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/f2795671-13a9-4619-8599-fcf85dc2df17%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 

Michael Cawthon
Chief Investment Officer
Green Street Energy LLC
mcaw...@greenstenergy.com
p: 479-442-1407

JP

unread,
Oct 14, 2014, 5:29:58 PM10/14/14
to shiny-...@googlegroups.com
Actually,
 on further investigation my problem was that a different package was not playing well with dplyr and it was not a shiny issue at all

George Yang

unread,
Jan 28, 2016, 5:23:37 PM1/28/16
to Shiny - Web Framework for R
JP - i am having the same issue, which package was causing the issues for you?  Thanks
Reply all
Reply to author
Forward
0 new messages