Unhelpful dplyr error messages when using Shiny

dplyr normally produces useful error messages which you can dig deep into with rlang::last_trace() and rlang::last_error().

When running in Shiny, dplyr's error messages are not as helpful as the error messages for base R functions like [ which tell you in the error exactly where the issue is. The only way I am able to find dplyr errors in a shiny file where the error might occur in any of a number of sourced files is to set options(shiny.error = browser) and run rlang::last_error() or rlang::last_trace().

Is there a way I can set dplyr to return simpler error messages like [ from base and data.table, and to make sure that that simple error message appears in Shiny?

Here is my reprex:

library(shiny)
#> Warning: package 'shiny' was built under R version 3.6.3
library(dplyr)
#> Warning: package 'dplyr' was built under R version 3.6.3
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union

#options(shiny.error = browser) errors for dplyr are unfriendly without this, but base errors still very friendly.

first_function <- function(df){
  select(df, chad) #selecting for a non-existing column
  #df[,chad] #will work nicely
  
}

ui <- fluidPage(
  verbatimTextOutput("example")
)

server <- function(input, output, session) {
  output$example <- renderPrint({first_function(iris)})
}

shinyApp(ui, server)
#> PhantomJS not found. You can install it with webshot::install_phantomjs(). If it is installed, please make sure the phantomjs executable can be found via the PATH variable.

Shiny applications not supported in static R Markdown documents

Created on 2020-12-01 by the reprex package (v0.3.0)

And here is my sessionInfo:

R version 3.6.2 (2019-12-12)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)

Matrix products: default

locale:
[1] LC_COLLATE=English_South Africa.1252  LC_CTYPE=English_South Africa.1252    LC_MONETARY=English_South Africa.1252
[4] LC_NUMERIC=C                          LC_TIME=English_South Africa.1252    

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

other attached packages:
 [1] reprex_0.3.0      shiny_1.4.0.2     data.table_1.12.8 forcats_0.4.0     stringr_1.4.0     dplyr_1.0.2       purrr_0.3.3      
 [8] readr_1.3.1       tidyr_1.1.1       tibble_3.0.3      ggplot2_3.3.2     tidyverse_1.3.0  

loaded via a namespace (and not attached):
 [1] xfun_0.12        tidyselect_1.1.0 haven_2.2.0      colorspace_1.4-1 vctrs_0.3.2      generics_0.0.2   htmltools_0.4.0 
 [8] rlang_0.4.7      pillar_1.4.3     later_1.0.0      glue_1.4.1       withr_2.1.2      DBI_1.1.0        dbplyr_1.4.2    
[15] modelr_0.1.5     readxl_1.3.1     lifecycle_0.2.0  munsell_0.5.0    gtable_0.3.0     cellranger_1.1.0 rvest_0.3.5     
[22] evaluate_0.14    knitr_1.28       callr_3.4.1      fastmap_1.0.1    ps_1.3.0         httpuv_1.5.2     fansi_0.4.1     
[29] broom_0.7.0      Rcpp_1.0.3       xtable_1.8-4     clipr_0.7.0      scales_1.1.0     backports_1.1.5  promises_1.1.0  
[36] jsonlite_1.6.1   mime_0.8         fs_1.5.0         hms_0.5.3        digest_0.6.23    stringi_1.4.4    processx_3.4.1  
[43] grid_3.6.2       cli_2.0.2        tools_3.6.2      magrittr_1.5     whisker_0.4      crayon_1.3.4     pkgconfig_2.0.3 
[50] ellipsis_0.3.0   rsconnect_0.8.16 xml2_1.2.2       lubridate_1.7.4  rmarkdown_2.1    assertthat_0.2.1 httr_1.4.1      
[57] rstudioapi_0.11  R6_2.4.1         compiler_3.6.2

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.