r - R Shiny 应用程序不会上传文件或显示绘图
问题描述
希望有人能帮忙!
我正在尝试创建一个 R 闪亮的应用程序,它允许我上传文件以及在不同的选项卡中显示图。当我不引入选项卡时,我的文件上传代码有效 - 不知道为什么这会影响任何事情。
尽管代码在闪亮的应用程序之外工作,但我似乎也无法显示我的 ggplot。
这是我当前的代码(我知道我的小部件还没有做任何事情......):
ui <- fluidPage(
# Application title
titlePanel(h1("Title", align = "center")),
# Upload file
fileInput("upload", "Data file:", buttonLabel = "Select File", multiple = FALSE),
tableOutput("files"),
hr(),
# Tabs for Display Options
tabsetPanel(
tabPanel("Table 1", tableOutput("table")),
tabPanel("Plot1", plotOutput("distPlot")),
tabPanel("Table 2", tableOutput("table")),
tabPanel("Plot 2",plotOutput("distPlot")),
tabPanel("Summary", verbatimTextOutput("summary"))
),
# Sidebar with interactive widgets
sidebarLayout(
sidebarPanel(
# Radio Buttons for Data Normalization
radioButtons("radio", label = h3("Pick:"),
choices = list("1" = 1, "1" = 2), selected = 1),
hr(),
# Checkbox for whether outliers should be included
checkboxInput("outliers", "Show outliers", FALSE)
),
mainPanel(
h1("test...")
)
)
)
# Server
server <- function(input, output) {
# You can access the value of the widget with input$file
output$files <- renderTable(input$upload)
# Distribution Plots
output$distPlot <- renderPlot({
p <- ggplot(data=dat, aes(column1)) + geom_density(aes(y = ..count..), fill = "lightgray")
print(p)
})
}
# Run the application
shinyApp(ui = ui, server = server)
Dat 只是一个数据框,在 2 列(名为“column1”)的每一列中有 104 个值。不知道如何在这里分享,但可以是任何东西,只要我能让它显示出来。
谢谢!!
解决方案
推荐阅读
- string - 如何使用 SHELL SCRIPT 从简单日期字符串 (YYYYMMDD) 中获取 YEAR 信息?
- shell - 在子目录中创建包含以 C 开头的文件的 tar.gz 文件
- angular - 使用 takeUntil 后出现 ObjectUnsubscribedError
- java - Java 源文件在 IntelliJ 中显示为空的反编译类文件
- javascript - 如何打开新克隆的 Bootstrap 选择字段?
- python - 如何将 one_hot 编码标签传递到 flow_from_dataframe?
- vb.net - 如果 MDI 子最大化,则 MDI 父窗口高度在还原时缩小(最小化/最大化之后)
- tableau-api - 字段内的表计算百分比差异
- google-cloud-platform - 同步拉取 pubsub node.js
- python - 如何在需要时启用向下滚动功能?