no applicable method for 'group_by_' applied to an object of class "c('reactiveExpr', 'reactive')

4,148 views
Skip to first unread message

Omar André Gonzáles Díaz

unread,
Apr 29, 2017, 11:06:49 PM4/29/17
to Shiny - Web Framework for R
Hi, I'm getting the error shown in the subject: 

no applicable method for 'group_by_' applied to an object of class "c('reactiveExpr', 'reactive')


This is my R.Server code, I've looked in Google without results. Please, any hint to a possible solution is welcome. The dataset downloads from Dropbox with the "repmis" library, so you could reproduce it right away.


####R.Server:


library(shiny)
library(plotly)
library(dplyr)
library(repmis)
library(formattable)




### Data alojada en DropBox











server <- function(input, output) {
  
  
  output$plot <- renderPlotly({
    
    
    tvs.rango <- tvs %>%
      group_by(periodo, ecommerce, rango) %>%
      summarise(cantidad = length(rango))
    
    ggplotly(ggplot(tvs.rango, aes(x = rango, y = cantidad, fill = ecommerce)) +
               geom_bar(stat = "identity") + 
               scale_fill_manual("ecommerce",
                                 values = c("linio" = "#FF5500","ripley" = "#802D69","falabella" = "#BED800")) +
               facet_grid(~ periodo) +
               theme_bw() +
               coord_flip() +
               #theme_ipsum_rc(grid = "X") +
               theme(axis.text.x = element_text(colour="grey10",size=10,hjust=.5,vjust=.5,face="plain"),
                     axis.text.y = element_text(colour="grey10",size=10,hjust=1,vjust=0,face="plain"),  
                     axis.title.x = element_text(colour="grey40",size=16,angle=0,hjust=.5,vjust=0,face="plain"),
                     axis.title.y = element_text(colour="grey40",size=16,angle=90,hjust=.5,vjust=.5,face="plain"),
                     plot.title = element_text(size = 24,vjust=4, face="bold"),
                     plot.subtitle = element_text(vjust=2, size = 16),
                     plot.caption = element_text(vjust=2, size = 16),
                     panel.border = element_rect(colour = "white"),
                     legend.position = "none",
                     strip.text = element_text(size = 18, hjust = 0.01, vjust = -0.5),
                     strip.background = element_rect(colour = "white", fill = "white"),
                     panel.grid.major.y = element_blank(),
                     panel.grid.minor.y = element_blank()) +
               #geom_text(aes(label=cantidad), hjust=-0.25, size = 4) +
               ylim(0, 300) +
               labs(title = "", subtitle = "", caption = "",
                    x = "", y = ""))
    
  })
  
  
  
  
}



###R.ui


library(shiny)
library(shinydashboard)
library(plotly)
library(formattable)

sidebar <- dashboardSidebar(
  sidebarMenu(
    menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
    menuItem("Widgets", icon = icon("th"), tabName = "widgets",
             badgeLabel = "new", badgeColor = "green")
  )
)



body <- dashboardBody(
  tabItems(
    tabItem(tabName = "dashboard",
            plotlyOutput("plot"),
            verbatimTextOutput("event")
    ),
    
    tabItem(tabName = "widgets",
            h2("Widgets tab content"),
            formattableOutput("table")
    )
  )
)



# Put them together into a dashboardPage
dashboardPage(skin = "yellow",
  dashboardHeader(title = "Simple tabs"),
  sidebar,
  body
)



!!!====================================!!!


> sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=Spanish_Peru.1252 
[2] LC_CTYPE=Spanish_Peru.1252   
[3] LC_MONETARY=Spanish_Peru.1252
[4] LC_NUMERIC=C                 
[5] LC_TIME=Spanish_Peru.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets 
[6] methods   base     

other attached packages:
[1] repmis_0.5           dplyr_0.5.0         
[3] formattable_0.2.0.1  plotly_4.6.0        
[5] ggplot2_2.2.1        shinydashboard_0.5.3
[7] shiny_1.0.3         

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.10      compiler_3.4.0    plyr_1.8.4       
 [4] R.utils_2.5.0     R.methodsS3_1.7.1 tools_3.4.0      
 [7] digest_0.6.12     R.cache_0.12.0    jsonlite_1.4     
[10] evaluate_0.10     tibble_1.3.0      gtable_0.2.0     
[13] viridisLite_0.2.0 DBI_0.6-1         crosstalk_1.0.0  
[16] curl_2.6          yaml_2.1.14       httr_1.2.1       
[19] stringr_1.2.0     knitr_1.15.1      htmlwidgets_0.8  
[22] rprojroot_1.2     grid_3.4.0        data.table_1.10.4
[25] R6_2.2.0          rmarkdown_1.5     purrr_0.2.2      
[28] tidyr_0.6.1       magrittr_1.5      scales_0.4.1     
[31] backports_1.0.5   htmltools_0.3.6   assertthat_0.2.0 
[34] mime_0.5          xtable_1.8-2      colorspace_1.3-2 
[37] httpuv_1.3.3      stringi_1.1.5     lazyeval_0.2.0   
[40] munsell_0.4.3     R.oo_1.21.0 



Winston Chang

unread,
May 1, 2017, 12:19:23 PM5/1/17
to Omar André Gonzáles Díaz, Shiny - Web Framework for R
You probably need to replace `tvs` with `tvs()` in this expression:
    tvs.rango <- tvs %>%
      group_by(periodo, ecommerce, rango) %>%
      summarise(cantidad = length(rango))

--
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-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/44b1909b-e830-40ec-8049-dc7929e0da46%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages