简体   繁体   English

部署 Shiny 应用程序会破坏 pivot; 无法指定具有非 vctrs 类型的原型

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

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.我正在使用 pivot_longer 到 pivot 一个表上的按钮按下 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:当我从 RStudio 运行应用程序时,这个 pivot 工作得很好,我得到了预期的结果:

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.但是,在部署时(使用 DesktopDeployR 或 RInno),按下按钮时屏幕变为灰色并且应用程序挂起。 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:有趣的是,gather() 工作得很好,但如果我能解决这个问题,我宁愿使用 pivot:

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

TaylorV's comment was really helpful in getting me to the solution. TaylorV 的评论对我找到解决方案非常有帮助。 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.需要将我的 vctrs package 更新到 0.3.0 版,RStudio 正在使用该版本,但是在同事计算机上编译的已部署应用程序的版本较旧。

I just deleted the old vctrs folder from the app/library folder and copy-pasted the newer version from my personal RStudio library.我刚刚从 app/library 文件夹中删除了旧的 vctrs 文件夹,并从我的个人 RStudio 库中复制粘贴了较新的版本。 Problem solved.问题解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM