I have a simple data frame in Shiny & would like to make a bar plot with plot_ly that would have conditional coloring based on the values (if profit > 0 green, else red). How to refer to a certain column in the color property?
 data<-reactive({names<-c("Initial", "New")
  revenue<-c(revenue1(),revenue2())
  costs<-c(input$costs, input$costs)
  profit1<-c(profit(), profit2())
  data<-data.frame(names, revenue, costs, profit1)
  data 
  })
  output$profit_bar<-renderPlotly(
    p<-data() %>%
      plot_ly(x = ~names, y = ~revenue, type = 'bar', name = 'Revenue', marker = list(color="#e5f4ea")) %>%
      add_trace(y = ~profit1, name = 'Profit',marker = list(color=ifelse(profit1>0,"#009933","FF6666"))) 
  )
I get an error: object 'profit1' not found. I also tried other options (e.g. data[,4] but no success. Outside shiny, the code is working correct.
Thank you for the answers!
