2
アップロードされたデータからプロットを作成するための光沢のあるアプリを作っています。入力ファイルの1つの列がカテゴリです。一意のカテゴリごとにチェックボックスを作成したいと思いますが、私には欠けているものがあると思います。 ui.R光沢のあるファイルに基づいてcheckBoxGroupを動的に作成
fluidPage(
titlePanel("Dynamic Check Boxes"),
fluidRow(
fileInput('file1', 'Upload a file'),
plotOutput('plot1'),
# This is where I'm trying to put the check boxes
uiOutput("ui")
)
)
は、ここに私のserver.R
categories = c()
test_data = NULL
function(input, output) {
# Trying to generate the check boxes
output$ui <- renderUI({
if (is.null(input$input_type))
return()
checkboxGroupInput('test', 'checkboxes', categories)
})
output$plot1 <- renderPlot({
inFile <- input$file1
if (is.null(inFile))
return(NULL)
test_data <<- read.table(inFile$datapath, head = F)
categories <<- unique(test_data$V1)
ggplot(test_data, aes(V2, V3)) + geom_point(aes(colour=V1))
})
}
私が使用してきたテストファイルです。
A 10 10
A 1 2
B 0 1
C 5 5
C 0 1
C 5 11
D 1 2