3
data.frameをファイルから読み込み、後でプロットを作成するのに使用したい。 問題は、データを読み込んだときに出力オブジェクトの一部であり、それ以上使用できないということです。私はcsvファイルのデータを使って多くの異なるプロットを作成したいと思っています。 ここでは、csvファイルに2つの列がある小さな例がありますが、機能サーバーの最後に何をしたいのですか。R shiny:ファイルからテーブルを読み込んで使用する
shiny::runApp(list(
ui=pageWithSidebar(
headerPanel('Simple matrixInput')
,
sidebarPanel(
fileInput('file1', 'Choose 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'),
radioButtons('dec', 'Desimal seperator',
c('komma'=",",
'punktum'="."), 'komma')
)
,
mainPanel(
tableOutput(outputId = 'table.output'),
plotOutput("plot1")
))
,
server=function(input, output){
output$table.output <- renderTable({
inFile <- input$file1
if (is.null(inFile))
return(NULL)
tbl <- read.csv(inFile$datapath, header=input$header, sep=input$sep, dec = input$dec)
return(tbl)
})
#I also want to do this:
# output$plot1 <- plot(tbl[,1], tbl[,2])
}
))
の一部は、あなたが 'reactive'でファイルを読み込むしようとしたことがありますか? – user5029763