shinyapps.io version application is different from local shiny apps

546 views
Skip to first unread message

Leon Kim

unread,
Aug 14, 2015, 3:29:49 PM8/14/15
to ShinyApps Users
Hello,

I've been developing shiny apps for a while, and I encountered this bug. When I run shiny apps on Rstudio locally, all the graphics are correctly displayed. When I deploy this to shinyapps.io, the graphics are all wrong (values are different across all plots, but plot structure is correct). For example, if I see bar plot with bar values 10%, 40% , and 50% , then the shinyapps.io version shows completely different values.

I am lost at how I can trouble shoot this. I have always deployed shiny apps to shinyapps.io and worked fine. What is the cause of this?

Tareef Kawaf

unread,
Aug 14, 2015, 4:29:52 PM8/14/15
to Leon Kim, ShinyApps Users
Without trying to see the example directly, it is hard to tell.  I have seen some variances in application performance in the past where the mismatch of locales can affect the data that is shown, usually due to sorting or timezones/dateranges.  Do you think any of the variances you are seeing could be attributed to that?  

--
You received this message because you are subscribed to the Google Groups "ShinyApps Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shinyapps-use...@googlegroups.com.
To post to this group, send email to shinyap...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shinyapps-users/2f93d2fa-cf0a-42d6-850d-81e096f4963f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Leon Kim

unread,
Aug 15, 2015, 12:36:57 AM8/15/15
to ShinyApps Users, hakji...@gmail.com
I don't have any time-related data. I pull the data straight out of mongoDB using library(rmongodb). I did not have this problem until August 14. Before that I pushed to shinyapps.io without any problem.
I attempted to read the data locally (not from mongoDB). This has not solved the issue. One thing I forgot to mention is that I got an error report when I deployed my apps. If this error occurs, my app does not get deployed. When I attempt to publish again, sometimes the deployment works... but with values not matching as described in the first post. The error report when I try to deploy looks like: 

-------------- Start of error log, copied from Rstudio log -------------------------
Preparing to deploy application...DONE
Uploading bundle for application: 55309...DONE
Deploying bundle: 240271 for application: 55309 ...
Waiting for task: 67211891
  building: Parsing manifest
  building: Building image: 235573
  building: Installing packages
  building: Installing files
  building: Pushing image: 235573
################################## Begin Log ################################## 
[2015-08-15T04:22:52.920824205+0000] Installing R package: xtable (1.7-4)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �xtable� ...
* DONE (xtable)
[2015-08-15T04:22:53.249610303+0000] Installing R package: magrittr (1.5)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �magrittr� ...
* DONE (magrittr)
[2015-08-15T04:22:53.672970504+0000] Installing R package: labeling (0.3)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �labeling� ...
* DONE (labeling)
[2015-08-15T04:22:53.965181850+0000] Installing R package: R6 (2.1.0)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �R6� ...
* DONE (R6)
[2015-08-15T04:22:54.316443232+0000] Installing R package: RColorBrewer (1.1-2)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �RColorBrewer� ...
* DONE (RColorBrewer)
[2015-08-15T04:22:54.604049146+0000] Installing R package: yaml (2.1.13)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �yaml� ...
* DONE (yaml)
[2015-08-15T04:22:54.926629133+0000] Installing R package: proto (0.3-10)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �proto� ...
* DONE (proto)
[2015-08-15T04:22:55.280608331+0000] Installing R package: dichromat (2.0-0)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �dichromat� ...
* DONE (dichromat)
[2015-08-15T04:22:55.653572171+0000] Installing R package: digest (0.6.8)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �digest� ...
* DONE (digest)
[2015-08-15T04:22:55.953291500+0000] Installing R package: mime (0.3)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �mime� ...
* DONE (mime)
[2015-08-15T04:22:56.224594666+0000] Installing R package: stringi (0.5-5)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �stringi� ...
* DONE (stringi)
[2015-08-15T04:22:58.774633015+0000] Installing R package: stringr (1.0.0)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �stringr� ...
* DONE (stringr)
[2015-08-15T04:22:59.056315651+0000] Installing R package: htmltools (0.2.6)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �htmltools� ...
* DONE (htmltools)
[2015-08-15T04:22:59.334776820+0000] Installing R package: gtable (0.1.2)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �gtable� ...
* DONE (gtable)
[2015-08-15T04:22:59.616427703+0000] Installing R package: colorspace (1.2-6)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �colorspace� ...
* DONE (colorspace)
[2015-08-15T04:22:59.933681631+0000] Installing R package: munsell (0.4.2)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �munsell� ...
* DONE (munsell)
[2015-08-15T04:23:00.223912294+0000] Installing R package: MASS (7.3-43)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �MASS� ...
* DONE (MASS)
[2015-08-15T04:23:00.601334764+0000] Installing R package: Rcpp (0.12.0)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �Rcpp� ...
* DONE (Rcpp)
[2015-08-15T04:23:02.086935338+0000] Installing R package: plyr (1.8.3)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �plyr� ...
* DONE (plyr)
[2015-08-15T04:23:02.425318473+0000] Installing R package: reshape (0.8.5)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �reshape� ...
* DONE (reshape)
[2015-08-15T04:23:02.713477257+0000] Installing R package: reshape2 (1.4.1)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �reshape2� ...
* DONE (reshape2)
[2015-08-15T04:23:03.032605012+0000] Installing R package: httpuv (1.3.3)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �httpuv� ...
* DONE (httpuv)
[2015-08-15T04:23:03.460167076+0000] Installing R package: scales (0.2.5)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �scales� ...
* DONE (scales)
[2015-08-15T04:23:03.769739902+0000] Installing R package: jsonlite (0.9.16)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �jsonlite� ...
* DONE (jsonlite)
[2015-08-15T04:23:04.222990375+0000] Installing R package: rmongodb (1.8.0)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �rmongodb� ...
* DONE (rmongodb)
[2015-08-15T04:23:04.591077017+0000] Installing R package: htmlwidgets (0.5)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �htmlwidgets� ...
* DONE (htmlwidgets)
[2015-08-15T04:23:04.977098470+0000] Installing R package: DT (0.1)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �DT� ...
* DONE (DT)
[2015-08-15T04:23:05.418149539+0000] Installing R package: shiny (0.12.2)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �shiny� ...
* DONE (shiny)
[2015-08-15T04:23:06.199162328+0000] Installing R package: shinythemes (1.0.1)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �shinythemes� ...
* DONE (shinythemes)
[2015-08-15T04:23:06.585881944+0000] Installing R package: ggplot2 (1.0.1)
* installing to library �/usr/local/lib/R/site-library�
* installing *binary* package �ggplot2� ...
* DONE (ggplot2)
Generating locales...
  en_US.UTF-8... done
Generation complete.
[2015-08-15T04:23:08.812144308+0000] Creating dir /srv/connect/apps/BGAK_App_August
[2015-08-15T04:23:08.820407581+0000] Copying file server_new.R      # backup server.R file. The problem of mismatching apps happened before this file existed
[2015-08-15T04:23:08.829513237+0000] Copying file server.R
[2015-08-15T04:23:08.838190223+0000] Copying file loadDataFromMongoDB.R    # This was not sourced by server.R or ui.R when this error log was created
[2015-08-15T04:23:08.847126618+0000] Copying file Thumbs.db
[2015-08-15T04:23:08.855857553+0000] Copying file .Rhistory
[2015-08-15T04:23:08.864855343+0000] Copying file ui.R
[2015-08-15T04:23:08.873555577+0000] Copying file helper_function.R
[2015-08-15T04:23:08.882459659+0000] Copying file data.csv      # my attempt to locally load data instead of mongoDB
################################### End Log ################################### 
Error: Unhandled Exception: HTTP 599: Timeout
Execution halted

------------- End of Log -----------------------

I was planning to upgrade to non-free version after my development was finalized. I don't think this is a free-version vs premium-version issue. This issue popped up within couple days.

Thanks for the help.

Leon Kim

unread,
Aug 16, 2015, 11:38:19 PM8/16/15
to ShinyApps Users, hakji...@gmail.com
Beyond the HTTP timeout errors (which is solved if I attempt to deploy again), I found the reason to the different values. In my app, I use ddply in library(plyr) to do the following:

ddply(df_subset, c(x,"Question"), summarize, perc_yes=length(which(value == "YES"))/length(value),
                             perc_yes_label
=paste0(" ",round(length(which(value == "YES"))/length(value)*100),"d))

The function pretty much splits data.frame df_subset by variables "x" and "Question" and count the number of "value" that is equal to "YES" to calculate proportion of YES in the subgroups. The variable "value" is either UNKNOWN, YES, or NO. In the local shiny app, the above code calculates the correct proportion of YES in each subgroup, but in shinyapps.io deployment, the code calculates the proportion of NO. After testing out all the possible cases, I found out the following:

          # when "YES" in local shiny is deployed, shinyapps.io shows "NO" values
          # when "NO" in local shiny is deployed,  shinyapps.io shows "UNKNOWN" values
          # when "UNKNOWN" in local shiny is deployed, shinyapps.io shows "YES" values

My suspicion is that this has to do with factor levels. In my data, the variable "value" in "df_subset" is not a factor. When you factor "value" (i.e. factor(df_subset$value) ), the factor levels are "NO", "UNKNOWN", and "YES" alphabetically by R default. 

I am wondering why this is happening. I am adding my sessionInfo as an additional data.

R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)

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] grid      stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] DT_0.1            scales_0.2.5      reshape2_1.4.1    shinythemes_1.0.1 shiny_0.12.2      ggplot2_1.0.1     rmongodb_1.8.0   
[8] gtable_0.1.2      plyr_1.8.3       

loaded via a namespace (and not attached):
 [1] bitops_1.0-6     colorspace_1.2-6 digest_0.6.8     htmltools_0.2.6  htmlwidgets_0.5  httpuv_1.3.3     jsonlite_0.9.16 
 [8] labeling_0.3     magrittr_1.5     MASS_7.3-43      mime_0.3         munsell_0.4.2    proto_0.3-10     R6_2.1.0        
[15] Rcpp_0.12.0      RCurl_1.95-4.7   RJSONIO_1.3-0    rsconnect_0.3.79 rstudioapi_0.3.1 stringi_0.5-5    stringr_1.0.0   
[22] tools_3.1.2      xtable_1.7-4   


On Friday, August 14, 2015 at 4:29:52 PM UTC-4, Tareef Kawaf wrote:

Tareef Kawaf

unread,
Aug 17, 2015, 9:03:00 AM8/17/15
to Leon Kim, ShinyApps Users
I don't think any of us have experience with plyr, but let me ask some of our other R developers internally to see if they have any working theories on why this might have started happening on shinyapps.io.  I can't think of anything that would have caused that to occur.

-Tareef

Tareef Kawaf

unread,
Aug 17, 2015, 9:22:29 AM8/17/15
to Leon Kim, ShinyApps Users
Hi Leon,
Here is what I heard back from one of our engineers:


Perhaps it's a stringsAsFactors problem? They might be setting locally
(e.g. in .Rprofile), so it's not the same on shinyapps?   suspect the
output of str(df_subset) would be informative.

Also please tell them that a better way of doing

perc_yes=length(which(value == "YES"))/length(value)

is

perc_yes = mean(value == "YES")


Do you want to try being explicit with stringsAsFactors?

-Tareef

Leon Kim

unread,
Aug 17, 2015, 9:51:55 AM8/17/15
to ShinyApps Users, hakji...@gmail.com
df_subset$value is a character vector. I have tried making it into a factor variable first, but the problem still there. For a quick fix I can compare the wrong value to compute the perc_yes, but I am wondering if this problem means I shouldnt use plyr functions with shinyapps.io 

As for stringAsFactors and locally defined options, I also have tried installing Shiny server on a private server and ran the app in the server. Same problem.  

Tareef Kawaf

unread,
Aug 17, 2015, 9:54:26 AM8/17/15
to Leon Kim, ShinyApps Users
Just to be clear Leon, are you saying that you see this issue on a locally run shiny server?  

Leon Kim

unread,
Aug 17, 2015, 10:19:27 AM8/17/15
to ShinyApps Users, hakji...@gmail.com
No. I am seeing on both, shinyapps.io and locally run shiny server. The results on the on-line shiny server are different from results on off-line shiny apps (via Rstudio)

Tareef Kawaf

unread,
Aug 17, 2015, 10:45:06 AM8/17/15
to Leon Kim
Okay, so this is not a shinyapps.io issue at all.  Moving it off shinyapps-users.  Do you think you can create a simple application that illustrates the difference you are seeing so I can share it with our engineers internally?



yuri lim

unread,
Nov 27, 2016, 9:15:24 AM11/27/16
to shinyapps.io Users
hi~i've the same problem with you. So, did you solve your problem? I create a radar plot in my shiny, but there've the different result between in my local Rstudio and in my shinyapps.io. I try so many times but this problem always in there. I've never seen this problem before, it make me so down.
Reply all
Reply to author
Forward
0 new messages