r - Subset a Column of a dataframe stored as a reactive expression eventReactive -


forgive non-reproducible example. theoretical solution fine. want know how subset dataframe stored in reactive expression 1 particular column, be assigned unique output_id, , displayed in ui. analogous accessing column of dataframe so: df$column_name


i store dataframe reactive expression called data(), using eventreactive() linked actionbutton() in ui.

code in environment:

# dataframe n columns , k rows df  

ui:

actionbutton(inputid = "go", label = "update") 

server:

# create reactive expression 'data()', subsetted data.frame based on other reactive values  data() <- eventreactive( input$go, { df %>% filter(based on other reactive values) } )  output$output_id <- rendersomething( { code depends on data()$specific column }) 

may following example answers after. ui has multi select list, entries of lists can used subset species column of iris data set.

# using multi select list sum columns library(shiny) library(dplyr) # define ui application draws histogram ui <- fluidpage(   # application title   titlepanel("subset , sum column of iris"),    fluidrow(      selectinput('species', 'species', levels(iris$species), multiple = true, selectize = false)    ),    fluidrow(verbatimtextoutput('selection')),   fluidrow(tableoutput('datacolumn')),   fluidrow(     tags$h2("sum:"),     verbatimtextoutput('sum')   ) )  # define server logic required draw histogram server <- function(input, output) {   output$selection <- reactive(input$species)   subiris = reactive({     subset(iris, species %in% input$species)   })   output$datacolumn <- rendertable(subiris()$sepal.length)  output$sum <- renderprint(sum(subiris()$sepal.length))  }    # run application  shinyapp(ui = ui, server = server) 

Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -