【发布时间】:2018-11-09 07:43:59
【问题描述】:
我正在尝试在闪亮的应用程序中包含图像。我想要:“如果是类型 1 绘制“此图像”,如果是类型 0 绘制“其他图像”。我知道我必须将 jpg 文件放入 app.R 所在的文件夹中,然后调用它但我不知道怎么做。
这是我迄今为止使用的代码(它有效),我只需要将图像包含在渲染中。
library(shiny)
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel("Myapp"),
#Inputs
dateInput(inputId = "dob", label="Birth"),
dateInput(inputId = "ad", label="Date"),
actionButton("Submit", icon("fas fa-magic"), label="Submit"),
#Outputs
textOutput(outputId = "textR"),
imageOutput(outputId = "imageR1"),
imageOutput(outputId="imageR2")
)
# Define server logic required to draw a histogram
server <- function(input, output) {
#my output should be named textR and imageR1, imageR2
observeEvent(input$Submit,
output$textR<-renderText({
v1<-as.numeric(as.Date(input$ad,format="%Y/%m/%d") - as.Date(input$dob, format="%Y/%m/%d"))/30.5
value_v1<-ifelse(v1>48, "type1", "type2")
print(value_v1)
}))
}
# Run the application
shinyApp(ui = ui, server = server)
【问题讨论】:
标签: r shiny shiny-server