error after uploading .RData file
shirley-jin opened this issue · 21 comments
Hi,
Thanks for the great package! I just tried to use it for the first time, but met a problem after uploading my .RData file into browser. The error info shown in console is as below, and the webpage will be covered in translucent gray. May I know how to solve this? Thanks a lot!!
Warning: Error in map$get: key must be not be "" or NA
141: map$get
140: .values$get
139: .subset2(x, "impl")$get
138: [[.reactivevalues
136: <reactive:tlabels> [/Library/Frameworks/R.framework/Versions/3.6/Resources/library/stminsights/app/app.R#837]
120: tlabels
114: <reactive:topicDocs> [/Library/Frameworks/R.framework/Versions/3.6/Resources/library/stminsights/app/app.R#1291]
98: topicDocs
97: renderDataTable
96: func
83: origRenderFunc
82: output$tlabel
2: runApp
1: run_stminsights
Warning: Error in map$get: key must be not be "" or NA
123: <Anonymous>
Warning: Error in map$get: key must be not be "" or NA
49: <Anonymous>
Hi,
I have not seen this error before. Have checked that your .RData
file is structured as described in the package vignette and github readme? It needs to include
- one or several stm objects.
- one or several estimateEffect objects.
- an object
out
which was used to fit your stm models.
Naming is important, meaning that if stminsights cannot find an out
object, it will not work properly.
Hi,
I have not seen this error before. Have checked that your
.RData
file is structured as described in the package vignette and github readme? It needs to include
- one or several stm objects.
- one or several estimateEffect objects.
- an object
out
which was used to fit your stm models.Naming is important, meaning that if stminsights cannot find an
out
object, it will not work properly.
Hi,
Thanks for your reply. I checked my .RData
file, it does include several estimateEffect objects, stm objects, and an out
object. The display of the webpage is like below. I tried to reinstall it several times, but it seems that this error keeps happening.
Okay, then I need to dig a lil deeper. Could you share with me any .RData file which leads to this error? I would try to reproduce it locally to get a better understanding for what is going on.
Hi,
Github does not allow to upload file larger than 10 MB, so I sent it to you by email. Please let me know if you need any other info on this. Thanks.
Thanks, got it! Your .RData file came with some encoding issues and you stored your main textual variable as a factor variable. I used the following script to fix it:
load("bcorp.RData")
# https://stackoverflow.com/questions/34024654/reading-rdata-file-with-different-encoding
fix.encoding <- function(df, originalEncoding = "ISO-8859-1 ") {
numCols <- ncol(df)
df <- data.frame(df)
for (col in 1:numCols)
{
if(class(df[, col]) == "character"){
Encoding(df[, col]) <- originalEncoding
}
if(class(df[, col]) == "factor"){
Encoding(levels(df[, col])) <- originalEncoding
}
}
return(as_tibble(df))
}
out$meta <- fix.encoding(out$meta)
out$meta$document <- as.character(out$meta$document)
rm(processed, storage, fix.encoding)
save.image("bcorp_clean.RData")
Please try it out and let me know whether this solves your problem (it works for me).
Hi,
Thanks for the solution. I just tried the script to fix the encoding issue, but the same error still occurred. The error information shown in RStudio console after I uploaded the .RData file is the same as that I mentioned in the first post. I also tried it on both Windows and Mac, but still got the same error.
Warning: Error in map$get: key must be not be "" or NA
141: map$get
140: .values$get
139: .subset2(x, "impl")$get
138: [[.reactivevalues
136: <reactive:tlabels> [/Library/Frameworks/R.framework/Versions/3.6/Resources/library/stminsights/app/app.R#837]
120: tlabels
114: <reactive:topicDocs> [/Library/Frameworks/R.framework/Versions/3.6/Resources/library/stminsights/app/app.R#1291]
98: topicDocs
97: renderDataTable
96: func
83: origRenderFunc
82: output$tlabel
2: runApp
1: run_stminsights
Warning: Error in map$get: key must be not be "" or NA
123: <Anonymous>
Warning: Error in map$get: key must be not be "" or NA
49: <Anonymous>
Okay, then I would please need a little bit more info. Could you send me the output of sessionInfo()
after loading all the packages you use for one of your machines where the error occurs? Also, can you try using the .RData file I just sent you via e-mail and check whether the error still occurs?
Thanks!! I tried the .RData file you sent me, but still got the same error. I copied the output of sessionInfo()
below.
R version 3.6.1 (2019-07-05)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15.1
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
Random number generation:
RNG: Mersenne-Twister
Normal: Inversion
Sample: Rounding
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] readr_1.3.1 dplyr_0.8.3 tibble_2.1.3 ggrepel_0.8.1
[5] stringr_1.4.0 ggraph_2.0.0 tidygraph_1.1.2 shinydashboard_0.7.1
[9] shinyBS_0.61 shiny_1.4.0 ggplot2_3.2.1 stm_1.3.3
[13] stminsights_0.3.0
loaded via a namespace (and not attached):
[1] tidyselect_0.2.5 shinyjs_1.0 purrr_0.3.3 graphlayouts_0.5.0 lattice_0.20-38
[6] colorspace_1.4-1 vctrs_0.2.0 htmltools_0.4.0 viridisLite_0.3.0 rlang_0.4.0
[11] pillar_1.4.2 later_1.0.0 glue_1.3.1 withr_2.1.2 tweenr_1.0.1
[16] lifecycle_0.1.0 munsell_0.5.0 gtable_0.3.0 fastmap_1.0.1 httpuv_1.5.2
[21] Rcpp_1.0.2 xtable_1.8-4 backports_1.1.5 scales_1.0.0 promises_1.1.0
[26] jsonlite_1.6 mime_0.7 farver_1.1.0 gridExtra_2.3 ggforce_0.3.1
[31] hms_0.5.2 digest_0.6.21 stringi_1.4.3 polyclip_1.10-0 grid_3.6.1
[36] tools_3.6.1 magrittr_1.5 lazyeval_0.2.2 crayon_1.3.4 tidyr_1.0.0
[41] pkgconfig_2.0.3 zeallot_0.1.0 MASS_7.3-51.4 Matrix_1.2-17 data.table_1.12.6
[46] assertthat_0.2.1 viridis_0.5.1 R6_2.4.0 igraph_1.2.4.1 compiler_3.6.1
Okay it seems that there are two main problems.
-
Unrelated to stminsights code, the latest version of htmltools is not compatible with shiny and the way it handles data tables:
rstudio/htmltools#143
This leads to datatables holding e.g. probability and frex terms to only include single characters.
Installing the development version of shiny should fix this:
devtools::install_github("rstudio/shiny")
-
Something that changed in Shiny 1.3- 1.4. affected the timings of reactive functions waiting for an input. The error you included above results from the reactive function
tlabels()
looking for UI elements for topic labels. At the time it is looking for these labels, they do not yet exist, which leads to theError in map$get: key must be not be "" or NA
problem. I already fixed this for launching the app (locally, not in github yet), but when one switches to a topic model with a different number of topics, the problem still persists.
I will keep looking for a solution, but if other folks such as @jonneguyt, @cpsievert or @daattali have an idea what exactly is going on here, I would be super happy about any hints.
Ran into the same issue a week ago, which I seemed to have on OSX (10.14), but not on windows (10). Currently don't have time to look into this, but it may be OS related. I was unable to find a quick fix that did not have knock on effects (see below).
I thought it was related the the format of variables, but upon changing them I still had the issue. I found a cheap hack that messed up the tables, so my fix was to simply use Windows in the meantime. If you need a file that will reproduce it, happy to share.
With my cheap hack there was an issue with keywords table (the frex, score, etc.), that seemed to be related to the first aspect that you mention. Upon changing the follow
for (i in tnames) { topiclabels[[i]] <- i }
the formatting of the table was off (one character per entry, number of entries equalling i). Given that I haven't helped to develop this part, I am out of depth as to what's happening. Happy to provide more input, but currently unable to chase this down.
Thanks for your fast response! I am afraid it is not only an OS issue though because I can reproduce the error on a Windows machine. The table formatting issues you mention should be fixed after installing the dev version of shiny (see above).
Can confirm that pulling the latest version of shiny makes the table formatting issues go away... So indeed not OS related (I think my windows machine was lagging updates for several packages). No clue what else is happening, but the cheap hack above makes things work. Other than that, out of depth...
Okay it seems that there are two main problems.
- Unrelated to stminsights code, the latest version of htmltools is not compatible with shiny and the way it handles data tables:
rstudio/htmltools#143
This leads to datatables holding e.g. probability and frex terms to only include single characters.
Installing the development version of shiny should fix this:
devtools::install_github("rstudio/shiny")
- Something that changed in Shiny 0.3- 0.4. affected the timings of reactive functions waiting for an input. The error you included above results from the reactive function
tlabels()
looking for UI elements for topic labels. At the time it is looking for these labels, they do not yet exist, which leads to theError in map$get: key must be not be "" or NA
problem. I already fixed this for launching the app (locally, not in github yet), but when one switches to a topic model with a different number of topics, the problem still persists.I will keep looking for a solution, but if other folks such as @jonneguyt, @cpsievert or @daattali have an idea what exactly is going on here, I would be super happy about any hints.
Hello. Thank you very much for the 'stminsights' package.
There is same issue for my computer, so I update 'shiny' package on github.
Unfortunately, I encounter the same problem.
How can I solve the problem?
I am working on it and let you know as soon as I found a solution. In the meantime, what you could also try is downgrading shiny, e.g. to 1.3:
require(devtools)
install_version("shiny", version = "1.3.0", repos = "http://cran.us.r-project.org")
I am working on it and let you know as soon as I found a solution. In the meantime, what you could also try is downgrading shiny, e.g. to 1.3:
require(devtools) install_version("shiny", version = "1.3.0", repos = "http://cran.us.r-project.org")
Thank you for reply.
This solution saves me.
I just pushed an update to stminsights which hopefully fixed all the bugs introduced by the Shiny changes. Please try reinstalling with devtools::install_github("cschwem2er/stminsights")
and let me know if this works for you.
Also, in case the app does not crash, please try to compare the output of the app with that returned by the stm
package and let me know when you find anything suspicious.
@NinaRizun This current build of stminsights relies on development versions of packages that are only available on Github. So you need 1) Rtools properly installed and 2) to choose the first option when installing stminsights from Github.
I suggest to restart your R environment and then trying it again. The error message you receive suggests that the installation failed because you had some of the packages currently loaded ("are in use and will not be installed").
Works for me. One minor note, it seems that it needs the latest development version of shiny. For me, this resulted in an error without the option to automatically update all packages. I had to manually install the dev version of shiny, which can be done by
devtools::install_github("rstudio/shiny")
Thanks for the heads-up @jonneguyt. Yes, unfortunately the development version of Shiny is still necessary as their CRAN version does not yet have the bug fixed which messes up the output of data tables.