Я хочу использовать выбранные переменные в UI.r в Server.r - PullRequest
0 голосов
/ 20 января 2019

У меня есть флажок ввода в UI.R с использованием набора данных, загруженного в server.R, но когда я пытаюсь использовать набор столбцов в Server.R, мой флажок ввода исчезает из макета.

Последняя часть кода показывает, что я пытался включить в реактив

#Server.R
shinyServer(function(input, output) {



# 3 wczytywanie danych 
dataIn <- reactive({
    inFile <- input$fileInPath

    if (is.null(inFile)) {
        return(NULL)
    }
    read.table(file=inFile$datapath,sep=";",dec=",",header=T,stringsAsFactors=FALSE)
})


output$ListOfColumns <- renderUI({
  req(dataIn())
  columns <- colnames(dataIn())

  checkboxGroupInput("Columns", "Choose columns",columns)
})     

output$daneIn <- renderTable({
    ret <- rbind(
        head(dataIn(),5),
        tail(dataIn(),5)
    )

    return(ret)



},include.rownames=FALSE)

#ui.r


shinyUI(fluidPage(
tags$img(src="http://administracja.sgh.waw.pl/pl/dpir/obowiazki/PublishingImages/ksiega2019/SGHherbCMYK.png",  width = 150, heigh = 150),

sidebarLayout(

    sidebarPanel(
        # 2. Przegladarka do pobrania danych 
        fileInput("fileInPath", 
            label= h4("Import danych"), accept=("text/csv")),
        radioButtons('plott','Plot',c('ggplot2'='ggplot2', 'lattice'='lattice')
            ),
        radioButtons('format', 'Document format', c('PDF', 'HTML', 'Word'),
                     inline = TRUE),
        downloadButton('downloadReport',label="Wygeneruj raport"),
        uiOutput("ListOfColumns")

       ),
   mainPanel(

        # 5. zakladki wynikiwe 
        tabsetPanel(type = "tabs",

            # 6. wyswietlanie pobranych danych  
            tabPanel("Table", tableOutput("daneIn"))
 ))



#What I've tried to add

dataIn <- reactive({
    inFile <- input$fileInPath

    if (is.null(inFile)) {
        return(NULL)
    }
   d<- read.table(file=inFile$datapath,sep=";",dec=",",header=T,stringsAsFactors=FALSE)
   d <- d[c(input$Columns)]
   return(d)
})

Я ожидаю, что блестящий будет использовать только переменные, выбранные в checkboxinput. Теперь флажок ввода прекратил появляться (после добавления последней части кода к реактиву)

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...