Cris
Cris

Reputation: 335

Accent mark in R-Shiny app

I am new to shiny and am trying to input html tags for adding some header text but the words that contain an accent mark (as very usual in spanish) results in error. For example, the code below produces what I want:

library(shiny)
ui <- fluidPage(

  titlePanel("Titles"),
    sidebarLayout(
      sidebarPanel(  
        tagList(tags$h4("Geological Survey of Colombia"),
                tags$h2("Analitic Geochemistry Group"),
                tags$p("Text here"))),

    # Main panel for displaying outputs ----
    mainPanel()
    )
    )
server <- function(input, output) {}
shinyApp(ui, server)

But changing tags$h4("Geological Survey of Colombia") for tags$h4("Servicio Geológico Colombiano") results in the error:

 Warning in checkEncoding(file) :   The input file
 C:\Users\cparedes\Documents\Shiny\test/app.R does not seem to be
 encoded in UTF8 Warning in readLines(file, warn = FALSE) :   invalid
 input found on input connection
 'C:\Users\cparedes\Documents\Shiny\test/app.R' Error in parse(file,
 keep.source = FALSE, srcfile = src, encoding = enc) :   
 C:\Users\cparedes\Documents\Shiny\test/app.R:7:25: unexpected
 INCOMPLETE_STRING 6:       sidebarPanel(   7:        
 tagList(tags$h4("Servicio Geol
                            ^ Error in sourceUTF8(fullpath, envir = new.env(parent = globalenv())) :    Error sourcing
 C:\Users\cparedes\AppData\Local\Temp\RtmpOwSrGa\file132427ca68ec

How can Include the accent marks?

Upvotes: 3

Views: 2626

Answers (1)

user3736295
user3736295

Reputation: 160

You can solve this with "Save with encoding" your file in UTF-8. I had the same issue with accent marks and used this guide https://shiny.rstudio.com/articles/unicode.html

Upvotes: 5

Related Questions