1

I have an app that I'd like to deploy shinyapps.io, and am using the standard procedure (described here) to try and deploy it. Unfortunately, I keep getting this error message. enter image description here

After a few hours of debugging, I'm fairly sure that this happens because I try and read in a .csv file that contains non-ASCII characters (German Umlaute, e.g. Ä). I have tried the options described here (i.e. saving all relevant scripts and .csv files as UTF-8 files, as well as explicitly setting the encoding options to UTF-8 before deploying the app).

What else can I try, short of simply changing the characters in my CSV files (which I would really like to avoid)?

Thanks so much for your help!

An attempt at a minimal reproducible example is here.

The app code is here:

library(shiny)
library(formattable)
library(readxl)


fp = read.csv("./with1.csv",stringsAsFactors = FALSE,strip.white = TRUE)


ui <- fluidPage(
mainPanel(
 formattableOutput("t1"),
 tags$style("#t1 {color:steelblue;}"),
 tableOutput("t2")

)
)

server <- function(input, output, session) {


 output$t2 = renderTable({
   fp
 })


  output$t1 = renderFormattable({
    test = as.data.frame(matrix(ncol=4,nrow=1))
    colnames(test) = c("Price","Avy Risk","Tomorrow / This Week","Drive Time")
    test[1,]=c(paste("\U20AC","29"),"2","26cm/ 85cm","3h45m")

    formattable(test,
                align = c("c","c","c","c"),
                list(`Price` = formatter("span", style = ~ style(font.weight = "bold",color="#4187FF",
                                                                 border = "1px solid #4187FF",border.radius="4px",
                                                                 padding="3px")),
                     `Avy Risk` = formatter("span", style = ~ style(font.weight = "bold",color="#FF705A",
                                                                    border = "1px solid #FF705A",border.radius="4px",
                                                                    padding="3px")),
                     `Tomorrow / This Week` = formatter("span", style = ~ style(font.weight = "bold",color="#5cb85c",
                                                                                border = "1px solid #5cb85c",border.radius="4px",
                                                                                padding="3px")),
                     `Drive Time` = formatter("span", style = ~ style(font.weight = "bold",color="#C13BFF",
                                                                      border = "1px solid #C13BFF",border.radius="4px",
                                                                      padding="3px"))

                )
    )
  })

}

shinyApp(ui, server)

The fp dataset (saved in an excel.csv file) looks like this:

[![enter image description here][4]][4]

After properly connecting RStudio to RSConnect, my deploy statement looks like this:

options(encoding = "UTF-8")
rsconnect::deployApp('C:/Users/fiscs14/Desktop/PowderHound/test')

I hope that this example is somewhat easily reproducible, and gives you an idea of the issue I'm running into.

seabass20
  • 227
  • 3
  • 14
  • Please see [this](https://stackoverflow.com/questions/48343080/how-to-convert-a-shiny-app-consisting-of-multiple-files-into-an-easily-shareable) question on how to share shiny examples. – ismirsehregal Apr 21 '20 at 21:26
  • I think that thread adequately addresses how to share a normal Shiny App. Unfortunately, however, my issue is with deployment to the shinyapps.io server, which requires a secret token, which would be unwise to share. I'll try to recreate an example, but it would require the answerer to have a shinyapps.io account and recreate it with that. – seabass20 Apr 22 '20 at 06:28
  • Ah, ok so you can't reproduce the behaviour in basic shiny. – ismirsehregal Apr 22 '20 at 10:17
  • Exactly, it requires a shinyapps.io account and can't be done just in basic shiny. – seabass20 Apr 22 '20 at 15:40

1 Answers1

1

Ok, so if there's anybody else that's interested in this, I've figured out a solution. I'm not sure why this works, but it is a practical workaround.

Instead of using read_csv, use read_excel. There are some SO questions as well as other guidance that indicates that the encoding in csv is a nightmare, so this seems to do it for non-ASCII characters.

seabass20
  • 227
  • 3
  • 14