iT邦幫忙

0

程式諮詢(我想用R 做某件事情,但是我不知道要怎麼用R 寫出來)

程式諮詢(我想用R 做某件事情,但是我不知道要怎麼用R 寫出來)

1.上傳檔案
2.按上傳檔案的column名稱做變項名稱
3.把變項名稱做為selectInput的選項(有多個條件做交集)
4.以selectInput選擇要使用的變項
5.選擇完畢後綜整以上條件
6.繪製直條圖或圓餅圖

目前小弟的程式如下,請指導如何完成上述,謝謝!

library(DT)
library(ggplot2)
library(shiny)
library(shinydashboard)

ui <- dashboardPage(
dashboardHeader(title = "QIS data-visualization"),
dashboardSidebar(
fileInput("data_file",
h3("上傳並匯入一個Excel檔案"),
accept=c("text/csv",
"text/comma-separated-values",
"text/plain",
".csv")
),
h5("請注意!", style = "color:red"),
h5("Excel副檔名須為csv且上傳檔案大小限制為50MB", style = "color:yellow"),
tags$hr(),
#表單摺疊按鈕
HTML("文件設定"),
#表單摺疊部分
div(id = "option1", class = "collapse in", #默認顯示:class="collapse in"
#第一行是不是變數
h3("是否需顯示頂端列"),
checkboxInput("header", "顯示頂端列", TRUE),
h5("請注意!", style = "color:red"),
h5("未打勾,系統將自行以一列變數定義之", style = "color:yellow"),
h3("請選擇文字編碼形式"),
radioButtons("enc", "文字編碼", c(utf8 = "UTF-8", big5 = "BIG5")),
h5("請注意!", style = "color:red"),
h5("Windows中文編碼請選擇BIG5", style = "color:yellow"),
h5("Linux/Mac中文編碼請選擇UTF-8", style = "color:yellow"),
)
),
dashboardBody(
fluidRow(
navbarPage(title = "Options",
tabPanel("數據", DTOutput("contents")))
)
)
)

server <- function(input, output, session) {

output$currentTime <- renderTable({
invalidateLater(1000, session)
paste("The current time is", Sys.time())
})

output$contents <- renderDT({
inFile <- input$data_file
if (is.null(inFile))
return(NULL)
read.csv(inFile$datapath, header=input$header, encoding = input$enc)
})
}

shinyApp(ui, server)

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答