R 如何在shiny中呈现单选按钮中的文本字段?
我需要转换列表中当前代码不运行的选项。函数tr在.csv字典中完成从一个术语到另一个术语的翻译R 如何在shiny中呈现单选按钮中的文本字段?,r,shiny,radio-button,R,Shiny,Radio Button,我需要转换列表中当前代码不运行的选项。函数tr在.csv字典中完成从一个术语到另一个术语的翻译 radioButtons( "enc", renderText({tr("Select encoding in case your data presents strange characters:")}), choices = c( renderText({tr("Automatic"
radioButtons(
"enc",
renderText({tr("Select encoding in case your data presents strange characters:")}),
choices = c(
renderText({tr("Automatic")}) = "unknown",
"UTF-8" = "UTF-8",
"Windows" = "Latin-1"
),
selected = "unknown",
inline = TRUE
)
目前的结果是:
Error in source("server/body.R", local = TRUE) :
server/body.R:86:48: unexpected '='
choices = c(
renderText({tr("Browse")}) =
^
一个可复制的例子将非常有用。让我们快速入门,让您确保答案符合您的要求 如果要使用动态ui元素,应该使用renderUI 你也应该仔细检查一些基础知识,。。。renderText生成和输出,不应在其他渲染函数中使用 我用以下方法模拟了tr功能:
tr尝试输出$automaticchoice
library(shiny)
tr <- function(name) return(paste("TR:", name))
ui <- fluidPage(
uiOutput("radio"),
plotOutput("distPlot")
)
server <- function(input, output) {
output$radio <- renderUI({
opt <- c("Normal" = "norm",
"Uniform" = "unif",
"Log-normal" = "lnorm",
"Exponential" = "exp")
names(opt)[1] <- tr("Normal")
label <- tr("Distribution type:")
radioButtons("dist", label, opt)
})
output$distPlot <- renderPlot({
dist <- switch(input$dist,
norm = rnorm,
unif = runif,
lnorm = rlnorm,
exp = rexp,
rnorm)
hist(dist(500))
})
}
shinyApp(ui, server)