r语言 - 调用 'gtsave()' 时"Error in s$close() : attempt to apply non-function"



我使用gt包来创建和保存我生成的表。最近,当我尝试gtsave时,有时会出现以下错误。

Error in s$close() : attempt to apply non-function

以下是会话信息:

> sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    
attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     
loaded via a namespace (and not attached):
[1] Rcpp_1.0.9          later_1.3.0         cellranger_1.1.0    pillar_1.8.1        compiler_4.1.1      tools_4.1.1        
[7] digest_0.6.29       jsonlite_1.8.0      googledrive_2.0.0   lifecycle_1.0.2     gargle_1.2.1        tibble_3.1.8       
[13] gtable_0.3.1        pkgconfig_2.0.3     rlang_1.0.5         svGUI_1.0.1         cli_3.4.0           rstudioapi_0.14    
[19] commonmark_1.8.0    curl_4.3.2          fastmap_1.1.0       webshot2_0.1.0      dplyr_1.0.10        stringr_1.4.1      
[25] generics_0.1.3      fs_1.5.2            vctrs_0.4.1         sass_0.4.2          svDialogs_1.1.0     websocket_1.4.1    
[31] googlesheets4_1.0.1 grid_4.1.1          tidyselect_1.1.2    chromote_0.1.1      glue_1.6.2          R6_2.5.1           
[37] processx_3.7.0      fansi_1.0.3         tidyr_1.2.1         purrr_0.3.4         ggplot2_3.3.6       magrittr_2.0.3     
[43] ps_1.7.1            promises_1.2.0.1    scales_1.2.1        htmltools_0.5.3     ellipsis_0.3.2      gt_0.7.0           
[49] colorspace_2.0-3    utf8_1.2.2          stringi_1.7.8       munsell_0.5.0

我可以再次install.packages("webshot"),然后重新运行我的代码,通常不会出现问题。然而,这不是一个好的解决方案。有人有什么建议吗?在更新了我的R、Rstudio和所有软件包后,我在两台不同的独立计算机(和代码(上重新创建了这个问题。

谢谢!

当我的计算机进入待机状态后返回R会话时,我通常会遇到这种情况。我找到了运行gtsave而不必重新启动R会话的解决方法:

f <- chromote::default_chromote_object() #get the f object
f$close()

请注意,它输出一个错误(Error in self$send_command(msg, callback = callback_, error = error_, : Chromote object is closed.(,但它似乎是可以忽略的。我现在可以在当前的R会话中像往常一样运行gtsave了。

最新更新