I develop my Shiny application in French and therefore I use special characters like "é"
(e
with an accent) "ê"
, "Œ"
, and so on. But these special characters do not work in renderUI
. For example, the category Pancréas (with "é"
) doesn't work properly unless I remove the é
and set the category as Pancreas. How can I make special characters work in renderUI?
library(shiny)
library(tidyverse)
TypeOfDisease<-c(rep("Infection",12),rep("Cancer",5),rep("Infection",14),
rep("Cancer",9),rep("Infection",8),rep("Cancer",7),rep("Infection",15),rep("Cancer",0),
rep("Infection",12),rep("Cancer",18))
Organ<-c(rep("Oesophage",17),rep("Stomach",23),rep("Lung",15),rep("Pancréas",15),rep("Liver",30))
data<-data.frame(TypeOfDisease,Organ)
addmargins(table(data$TypeOfDisease,dataF$Organ))
ui<-fluidPage(
sidebarLayout(
sidebarPanel(
selectInput("Organ","Select the organ",
choices = c("Total",levels(data$Organ))),
uiOutput("ui"),
),
mainPanel(
fluidRow(
column(5,tableOutput("table")),
column(7,
fluidRow(verbatimTextOutput("matrix")),
fluidRow(verbatimTextOutput("Nrow"))
)
)
)
)
)
server<-function(input,output){
output$ui<-renderUI(
switch (input$Organ,
"Total" = selectInput("TypeOfDis","Type of disease",
choices = c("Total","Infection","Cancer")),
"Oesophage" = selectInput("TypeOfDis","Type of disease",
choices = c("Total","Infection","Cancer")),
"Stomach" = selectInput("TypeOfDis","Type of disease",
choices = c("Total","Infection","Cancer")),
"Lung" = selectInput("TypeOfDis","Type of disease",
choices = c("Total","Infection","Cancer")),
"Pancréas" = selectInput("TypeOfDis","Type of disease",
choices = c("Total")),
"Liver" = selectInput("TypeOfDis","Type of disease",
choices = c("Total","Infection","Cancer")),
)
)
dataFilter<-reactive({
if(input$TypeOfDis=="Total"&input$Organ=="Total"){
data
}else {
if(input$TypeOfDis=="Total"){
data[data$Organ==input$Organ,]
}else if (input$Organ=="Total"){
data[data$TypeOfDisease==input$TypeOfDis,]
}else
data[data$TypeOfDisease==input$TypeOfDis & data$Organ==input$Organ ,]
}
})
output$table<-renderTable ({dataFilter()})
output$matrix<-renderPrint({addmargins(table(data$TypeOfDisease,dataF$Organ))})
output$Nrow<-renderPrint({nrow(dataFilter())})
}
shinyApp(ui,server)