У меня есть реактивные данные react$data
, и у меня есть два входа input$chosencolumn
, input$chosenrows
Как выбрать определенные строки в реактивном наборе данных в R Shiny
С реактивным набором данными, как бы я быть в состоянии указать строки, которые я хочу, как у data.frame где вы data[data$chosencolumn == chosenrows,]
Возпроизводимо пример:
server.R
### Start of Shiny server
shinyServer(function(input, output, session) {
reactdata <- reactiveValues()
observe({
if(is.null(input$fileinput)){return(NULL)}
else{reactdata$inputdata <- read.xlsx(input$fileinput$datapath, header=T, sheetIndex = 1)}
})
output$selectsamples <- renderUI({
if(is.null(input$fileinput)){return(NULL)}
selectInput("selectsamples",
label = h5("Samples"), choices = colnames(reactdata$inputdata),
selected="Sample")
})
output$sampleselected <- renderUI({
if(is.null(input$fileinput)){return(NULL)}
selectInput("sampleselected",
label = h5("sampleselected"), choices = unique(as.character(reactdata$inputdata[,input$selectsamples])),
selected="B")
})
output$selectdilutions <- renderUI({
if(is.null(input$fileinput)){return(NULL)}
selectInput("selectdilutions",
label=h5("Select Dilutions"),
choices = colnames(reactdata$inputdata),
selected="Dilution")
})
reactdata1 <- reactiveValues()
observe({
reactdata1$datatable1 <- datatable(reactdata$inputdata,
rownames = TRUE,
options = list(pageLength = 100, dom = 'tip'))
})
output$datatable1 <- renderDataTable({
reactdata1$datatable1
})
})
ui.R
require(shiny)
require(devtools)
require(grDevices)
require(xlsx)
require(DT)
shinyUI(fluidPage(
navbarPage("",inverse = FALSE,
tabPanel("Analyse")),
titlePanel(""),
fluidRow(
column(3,
wellPanel(
fileInput("fileinput", label = h5("Input file")),
uiOutput("selectsamples"),
uiOutput("sampleselected"),
uiOutput("selectdilutions")
)),
column(9,
fluidRow(
wellPanel(
uiOutput("sample1"),
dataTableOutput("datatable1"))
)))
)
)
Я хотел бы изменить reactdata1$datatable1
так, что она включает в себя только строки данных, выбранных SAMP le выбран (т.е. выбирается значение, выбранное в качестве входных $ samples).
Так, что-то вроде reactdata1$datatable1[input$selectsamples == input$sampleselected,]
Пример набора данных здесь: Dropbox link to excel file
воспроизводимый пример поможет – jangorecki
Я добавил один из них. – Kabau
не похож на [tag: data.table] – jangorecki