0

I have a Shiny app where you can upload a file, and the data is then processed and relevant outputs appear. This is working totally fine locally. However, I've deployed it with shinyapps.io and now although the app appears fine at first, clearly something is going wrong with the data processing.

I use data.table::fread() for .csv files and readxl::read_excel for excel files. If you upload a .csv file, the app grays out, whereas if you upload an excel file, the outputs appear but basically blank as if no data is there.

The key errors in the logs are all like this:

Warning in grepl(pattern, vector, ignore.case = ignore.case, fixed = fixed) : input string 2 is invalid in this locale

I've found a few relevant posts, although not specifically about different behaviour on deployed apps. Looking at this one, it seems like this is sometimes to do with different script types? One of the elements in the data is coordinates so maybe they are causing problems. For e.g. they might look like this: E025° 50' 38"E

I have different outputs for Sys.locale(). Locally I get

LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United Kingdom.1252;LC_MONETARY=English_United Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252

On the deployed app it's

LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.UTF-8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_IDENTIFICATION=C

I've tried using useBytes = TRUE as a gsub() and grepl() argument but then it causes other errors later on or else seems to make no difference.

Thanks for your help!

Jaccar
  • 1,720
  • 17
  • 46
  • I don't have a lot of experience with differing locales, but can you `Sys.setenv(LC_COLLATE=...)` (and `LC_TIME`) in the app? This might be sufficient when deployed. – r2evans Dec 21 '19 at 20:07
  • According to this https://community.rstudio.com/t/how-to-change-the-locale-on-shinyapps-io/24629 shinyapps will try to match your locale. Your deploy logs should have more info. – novica Dec 21 '19 at 22:25
  • Thanks both. So I've tried `Sys.setlocale("LC_ALL","C")` along with `Sys.setlocale("LC_MEASUREMENT", "C")`, `Sys.setlocale("LC_MESSAGES", "C")` and `Sys.setlocale("LC_PAPER", "C")`. This gives me the same output for my `Sys.locale()` but the same issue is happening in the deployed app (while the local app doesn't work because it is Windows). I would guess it might be about getting LC_MEASUREMENT right? I'm not sure what would be right though. – Jaccar Dec 21 '19 at 22:32
  • You didn't mention that the local app is not working as well. Maybe the you are trying to upload is corrupt? Maybe try with a simple csv file, one line, just to see if the one you are using is broken. – novica Dec 21 '19 at 23:05
  • Sorry, that wasn't clear - the local app does work normally, but when I made the changes in my comment, it stopped working, although the Sys.locale() output for the deployed app then seemed to match what it was locally when it was working. – Jaccar Dec 21 '19 at 23:23

0 Answers0