Я совершенно новый в блестящем, и я борюсь с реактивными объектами и кадром данных в блестящем.
Я хотел бы создать приложение, которое позволит пользователю загружать файл (например, .csv, .rds и т. Д.), Который будет «основой» всего процесса после.Идея состоит в том, что после загрузки файла некоторые панели будут отображать подмножества загруженной таблицы или новые таблицы, сделанные на основе вычислений на основе загруженной таблицы.
На самом деле сложность заключается в синтаксисе, особенно в том, как выбирать строки и столбцы из таблицы.Я ищу эквивалент df [c (1,2),] или df [, c (1,2)] или df $ variable_name в блестящем.
Вот мой код, я просто хочучтобы отобразить 1-й и 2-й столбцы входного файла, чтобы увидеть, в порядке ли обработанная мною обработка:
## Only run examples in interactive R sessions
library(sas7bdat)
ui <-fluidPage(navlistPanel(
tabPanel("Welcome",textOutput("welcome_message"),textOutput("welcome_message_2"),img(src="logo_danone.jpg", height = 350, width = 350)),
tabPanel("Input files", fileInput("file1", "Choose File",
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv")),
inputPanel(
tableOutput("contents")
)),
tabPanel("AUC Derivation",tableOutput("selection")),
tabPanel("AUC Derivation plots"),
tabPanel("Shape Analysis"),
tabPanel("Tables"),
tabPanel("Plots"),
tabPanel("Clustering"),
tabPanel("tab1",dataTableOutput("value")),
tabPanel("tab2",plotOutput("hist"))
))
server <-function(input, output) {
# You can access the value of the widget with input$file, e.g.
output$welcome_message <- renderText("test")
output$welcome_message_2 <- renderText("logo")
output$value <- renderDataTable({
iris
})
output$contents <- renderTable({
# input$file1 will be NULL initially. After the user selects
# and uploads a file, it will be a data frame with 'name',
# 'size', 'type', and 'datapath' columns. The 'datapath'
# column will contain the local filenames where the data can
# be found.
inFile <- input$file1
if (is.null(inFile))
return(NULL)
readRDS(inFile$datapath)
})
output$selection <- reactive({return(input$file1[,c(1,2)])})
#output$selected <- renderTable({selection()})
output$hist <- renderPlot({ # Refers to putputs with output$<id>
ggplot2::ggplot(data = iris, aes(y = Sepal.Length)) + geom_boxplot() # Refers to inputs with input$<id>
})
}
shinyApp(ui, server)
#}
Кто-нибудь может мне объяснить, как манипулировать загруженными таблицами через блестящий файл?
Заранее спасибо