Weird shinyj error when I work with s4 objects
jogugil opened this issue · 1 comments
I have a problem working with S4 objects.
When I try to use the removeClass function I get a weird shinyj error even though I don't use it. I have already read that it is a problem of the implementation of S4 errors but I would like to know how to solve it.
I have created my class:
setClass ("mldtf", slots = c (name = "character", file = "character", header = "logical", sep = "character", quote = "character", dec = "character", disp = "character "),
prototype = list (name = "my_mldtf", file = "FILE.CSV", header = TRUE, sep = "\ t", quote = "double", dec = '.', disp = "head"))
setValidity ("mldtf", function (object) {
validate (need (file.exists (object @ file), "Cannot find the entered file. Please check the file."))
validate (need (str_to_lower (tools :: file_ext (object @ file))% in% c ("csv", "txt", "sav", "xls", "xlsx", "rdata", "rds", " dat ")," Please upload a correct extension file .. "))
return (TRUE)
}
)
And a method that inherits from show:
setMethod ("show", ....)
Now I want to delete this class mldtf and this method for my own mldtf class and use the method;
removeClass ("mldtf ")
removeMethod ("show.mldtf ")
I know it's because it can't find it and it gives the shinyj error. But it is something strange because I am not even in a shiny project
sessionInfo ()
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)
Matrix products: default
locale:
[1] LC_COLLATE=Spanish_Spain.1252 LC_CTYPE=Spanish_Spain.1252 LC_MONETARY=Spanish_Spain.1252 LC_NUMERIC=C
[5] LC_TIME=Spanish_Spain.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] shinyjs_2.0.0 pryr_0.1.5 leaflet_2.0.4.1 scales_1.1.1 htmltools_0.5.2 rgdal_1.5-27 sp_1.4-6
[8] DT_0.20 forcats_0.5.1 purrr_0.3.4 readr_2.1.1 tidyr_1.1.4 tibble_3.1.6 tidyverse_1.3.1
[15] readxl_1.3.1 stringr_1.4.0 rvest_1.0.2 sf_1.0-4 shinydashboard_0.7.2 shinyWidgets_0.6.2 shiny.i18n_0.2.0
[22] plotly_4.10.0 ggplot2_3.3.5 dplyr_1.0.7 shiny_1.7.1
loaded via a namespace (and not attached):
[1] fs_1.5.1 lubridate_1.8.0 fontawesome_0.2.2 httr_1.4.2 rprojroot_2.0.2 tools_4.1.2
[7] backports_1.3.0 bslib_0.3.1 utf8_1.2.2 R6_2.5.1 KernSmooth_2.23-20 DBI_1.1.1
[13] lazyeval_0.2.2 colorspace_2.0-2 withr_2.4.3 tidyselect_1.1.1 compiler_4.1.2 cli_3.1.0
[19] xml2_1.3.3 desc_1.4.0 sass_0.4.0 classInt_0.4-3 proxy_0.4-26 digest_0.6.29
[25] pkgconfig_2.0.3 dbplyr_2.1.1 fastmap_1.1.0 htmlwidgets_1.5.4 rlang_0.4.12 rstudioapi_0.13
[31] jquerylib_0.1.4 generics_0.1.1 jsonlite_1.7.2 crosstalk_1.2.0 magrittr_2.0.1 Rcpp_1.0.7
[37] munsell_0.5.0 fansi_0.5.0 lifecycle_1.0.1 stringi_1.7.6 yaml_2.2.1 grid_4.1.2
[43] promises_1.2.0.1 crayon_1.4.2 lattice_0.20-45 haven_2.4.3 hms_1.1.1 pillar_1.6.4
[49] markdown_1.1 pkgload_1.2.4 codetools_0.2-18 reprex_2.0.1 glue_1.5.1 leaflet.providers_1.9.0
[55] data.table_1.14.2 modelr_0.1.8 vctrs_0.3.8 tzdb_0.2.0 httpuv_1.6.3 testthat_3.1.1
[61] cellranger_1.1.0 gtable_0.3.0 assertthat_0.2.1 cachem_1.0.6 xfun_0.28 mime_0.12
[67] xtable_1.8-4 broom_0.7.10 e1071_1.7-9 later_1.3.0 class_7.3-19 viridisLite_0.4.0
[73] units_0.7-2 ellipsis_0.3.2
Unfortunately this is an error because shinyjs was created many years ago, before I knew about S4 (or thought anybody would use this package!). The not-so-satisfying answer is that you should not load shinyjs (avoid library(shinyjs)
). If you're not loading shinyjs, then it seems one of your dependencies is, and you need to figure out where it's coming from.