我想知道是否有办法隐藏我闪亮的应用程序上的操作按钮,直到侧面板中显示变量选择.我一直无法通过按钮的uiOutput来实现这一点,因为它会混淆dataTable,因为它认为输入$ submit是一个空值.这是迄今为止的代码:
ui.R
library(shiny)
shinyUI(pageWithSidebar(
headerPanel("CSV Viewer"),
sidebarPanel(
fileInput('file1', 'CSV File',
accept=c('text/csv', 'text/comma-separated-values,text/plain', '.csv')),
tags$hr(),
checkboxInput('header', 'Header', TRUE),
radioButtons('sep', 'Separator',
c(Comma=',',
Semicolon=';',
Tab='\t'),
'Comma'),
uiOutput('varselect'),
actionButton('submit', 'Submit')
),
mainPanel(
dataTableOutput('contents')
)
))
Run Code Online (Sandbox Code Playgroud)
server.R
library(shiny)
shinyServer(function(input, output, session) {
observe({
csvfile <- input$file1
if (is.null(csvfile))
{return(NULL)}
dt <- read.csv(csvfile$datapath, header=input$header, sep=input$sep, quote=input$quote)
output$varselect <- renderUI({
checkboxGroupInput("var", "Variables", choices = names(dt), select = names(dt))
})
if (input$submit > 0) {output$contents <- renderDataTable({
isolate(dt[ ,input$var])
})}
})
})
Run Code Online (Sandbox Code Playgroud)
tl; dr我想阻止用户在选择要上传的文件之前按下"提交"按钮.事实证明这对我来说很难.
在此先感谢您的所有帮助!:)
我试图让这个ANOVA闪亮的应用程序运行没有运气.输出应该是一个列表,所以我可能会对如何输出这些数据类型感到困惑.有什么建议?
server.R
library(shiny)
library(car)
shinyServer(function(input, output) {
csvfile <- reactive({
csvfile <- input$file1
if (is.null(csvfile)){return(NULL)}
dt <- read.csv(csvfile$datapath, header=input$header, sep=input$sep)
dt
})
output$var <- renderUI({
if(is.null(input$file1$datapath)){return()}
else list (
radioButtons("dvar", "Please Pick The Dependent Variable", choices = names(csvfile())),
radioButtons("ivar", "Please Pick The Independent Variable", choices = names(csvfile())),
actionButton("submit", "Submit")
)
})
output$aovSummary = renderTable({
if (is.null(input$file1$datapath)){return()}
if (input$submit > 0) {
if (input$type == 'type1'){
isolate(anova(lm(csvfile()[,input$dvar] ~ csvfile()[,input$ivar], data = csvfile()))
}
if (input$type == 'type2'){
isolate(Anova(lm(csvfile()[,input$dvar] ~ csvfile()[,input$ivar], data …Run Code Online (Sandbox Code Playgroud)