Deploying Shiny app breaks pivot; Can't specify a prototype with non-vctrs types

74 views Asked by At

It's hard to provide a reprex for this because the issue only occurs when I use the deployed version of my app, but I'm hoping I can provide enough detail that someone will be able to help me understand what causes the issue. I am using pivot_longer to pivot a table on a button push in Shiny. My table is a little complex because some of the "cells" in the table must contain a list, not sure if that's part of the issue:

display_table <- tribble(~Project, ~Sample_Type, ~Date, ~Parameters, ~Units, ~A1, ~A7,       
"PL", "A", "14-May-2020",  "ARRIVE TIME", "", "10:00 am", "11:15 am",
"PL", "A", "14-May-2020",  "DEPART TIME", "", "10:20 am", "11:37 am",
"PL", "A", "14-May-2020",  "CREW", "", c("Joe", "Moe"), c("Jane", "Jack"))


final_table <<- display_table  %>%
  pivot_longer(
    .,
    cols = -c("Project", "Sample_Type", "Date", "Parameters", "Units"),
    names_to = "Station",
    values_to = "Values"
  )

This pivot works just fine when I'm running the app from RStudio, I get the expected outcome:

Project Sample_Type Date        Parameters  Units Station Values
1   PL  A           14-May-2020 ARRIVE TIME       A1      10:00 am
2   PL  A           14-May-2020 ARRIVE TIME       A7      11:15 am
3   PL  A           14-May-2020 DEPART TIME       A1      10:20 am
4   PL  A           14-May-2020 DEPART TIME       A7      11:37 am
5   PL  A           14-May-2020 CREW              A1      c("Joe", "Moe")
6   PL  A           14-May-2020 CREW              A7      c("Jane", "Jack")

However, when deployed (using DesktopDeployR or RInno), the screen goes gray on the button push and the app hangs. This is in the error log:

Warning: Error in : Can't specify a prototype with non-vctrs types.
vctrs methods must be implemented for class `AsIs`.
See <https://vctrs.r-lib.org/articles/s3-vector.html>.
  91: vec_c
  90: pivot_longer_spec
  89: pivot_longer
  88: function_list[[k]]
  86: freduce
  85: _fseq
  84: eval
  83: eval
  81: %>%
  80: observeEventHandler [C:\Users\smith\OneDrive\Documents\R\work_stuff\DesktopDeployR\app\shiny\/server.R#1353]
   9: shiny::runApp
application terminated normally

Interestingly, gather() works just fine, but I'd rather use pivot if I can solve the issue:

final_table <<- display_table  %>%
  gather("Station", "Values", -c("Project", "Sample_Type", "Date", "Parameters", "Units")) %>%
  select("Project", "Sample_Type", "Date", "Station", "Parameters", "Values", "Units")
1

There are 1 answers

0
srs025 On

TaylorV's comment was really helpful in getting me to the solution. Needed to update my vctrs package to version 0.3.0., which was in use by RStudio, but the deployed app, compiled on a co-workers computer, had an older version.

I just deleted the old vctrs folder from the app/library folder and copy-pasted the newer version from my personal RStudio library. Problem solved.