0

I am trying to set the x-axis limits of my reactive histograms in a shiny app to be constant. For example, regardless of the data i simulate, I would always like to have 200 breaks between 0 and 3000 (any frequencies spilling over 3000, or below 0, should be truncated out).

Is there a simple way of getting this done?

I've tried the following based on an idea here:

histSims <- reactive({
        #return
        hist(beanSims()[beanSims() > 1 & beanSims < 3000],
             breaks = 200,
             prob = T)

followed by

output$plot4 <- renderPlot({
        plot(histSims()                 
      ))
    })

But I get

Error: comparison (3) is possible only for atomic and list types
Community
  • 1
  • 1
val
  • 1,629
  • 1
  • 30
  • 56

1 Answers1

1

How about this code:

histSims <- reactive({
            #return
            beanSims_local<-beanSims()
            beanSims_local<-beanSims_local[beanSims_local> 1 & beanSims_local< 3000]
            hist(beanSims_local,
                 breaks = 200,
                 prob = T)
Otto_K
  • 347
  • 2
  • 6