0
votes

I have a constraints and according to that constraints i am assigning segments to customers. But i want to change constraints in ui and calculate segments immediately in background. So here is my code.

shinyServer(function(input, output) {


  Customer$Segment <- reactive({

onetimer <- input$onetimer 
firstcons <- input$firstcons 
secondcons <- input$secondcons 
rental1 <- input$rental1 
rental2 <- input$rental2 

ifelse(Customer$Rentals < rental1 & Customer$TotalPayment <= firstcons, "One-Timer",
......)

output$result <- renderText({Customer$Segment})

Listening on http://127.0.0.1:6199 Warning: Error in rep: attempt to replicate an object of type 'closure' 49: $<-.data.frame 47: server [\srvfps281\belge\clm24522\Segmentasyon/server.R#15] Error in rep(value, length.out = nrows) : attempt to replicate an object of type 'closure'

How can i edit my data with shiny?

1
Can you share a bit more code?Alexander Leow

1 Answers

0
votes

You are creating a reactive variable and you must address it a bit different way. However, please share a bit more code, since your code seems to have more than one problem. Apart from the variable addressing, renderText will not work with lists.

# create 
Customer <- reactive({
  # do something

  # return list
  return(list(Segment=list(onetimer=onetimer))) 
})

# output
output$result <- renderText({
  paste(unlist(Customer()$Segment),collapse="\n")
})