简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM