2

我是闪亮的新手,我正在尝试输入 html 标签来添加一些标题文本,但包含重音符号的单词(在西班牙语中很常见)会导致错误。例如,下面的代码产生了我想要的:

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)

但是更改tags$h4("Geological Survey of Colombia")导致tags$h4("Servicio Geológico Colombiano")错误:

 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

如何包含重音符号?

4

1 回答 1

3

您可以使用 UTF-8 格式的“使用编码保存”文件来解决此问题。我对重音符号有同样的问题,并使用了本指南https://shiny.rstudio.com/articles/unicode.html

于 2018-04-16T14:24:52.483 回答