title: Avoid multiple function calls in server shiny
body: <p>I have the following code in server function of a shiny app.</p>
  
  <p>To plot each type of chart I need to call the getPlotData() function each time. Is there any way I can avoid it to make the app faster? </p>
  
  <blockquote>
    <p>function</p>
  </blockquote>
  
  <pre><code> #This gets Sales data for selected client data
    getPlotData &lt;- reactive({
  
      inpParam &lt;&lt;- input$noc 
      getSalesData(inpParam)
      End_date &lt;&lt;- input$endDate    
  
      SalesClientData &lt;&lt;- GetSalesClientData()
      WeeklySales &lt;&lt;- GetWeeklyData()
      FortNightData &lt;&lt;- GetFortNightlyData()
      EWS &lt;&lt;- GetEWSData()
      MONTHLYSALES &lt;&lt;- GetMonthlyData()
      wtSafetyRatio &lt;&lt;- round(as.numeric(crossprod(MONTHLYSALES$SafetyRatio,MONTHLYSALES$Weights)/sum(MONTHLYSALES$Weights)),2)
      wtHealthScore &lt;&lt;- round(as.numeric(crossprod(MONTHLYSALES$HealthScore,MONTHLYSALES$Weights)/sum(MONTHLYSALES$Weights)),2)
      wtPaymentScore &lt;&lt;- round(as.numeric(crossprod(MONTHLYSALES$PaymentScore,MONTHLYSALES$Weights)/sum(MONTHLYSALES$Weights)),2)
      ROLLDATA &lt;&lt;- GetRollingData()
      EARLY_TOPUP &lt;&lt;- GetEarlyTopUp()
  
    })
  
    #DPD Plots
    output$DPDPLot&lt;-renderPlotly({
  
      getPlotData()
  
      plot_ly(data=SalesClientData, x = ~Date, y = ~DPD, name='DPD', type='scatter', mode = 'lines') %&gt;%
        add_trace(y = ~CHECKNACHDPD, name = 'CHEQUE-NACH Payment', type='bar') %&gt;% 
        add_trace(y = ~CHKNACHBounceDPD, name = 'CHEQUE-NACH Bounce', type='bar') %&gt;% 
        layout(title= "DPD Pattern", legend = list(orientation = "h"))
  
    })
  
    #Sales Plot
    output$SalesPlot&lt;-renderPlotly({
  
      getPlotData()
  
      SalesDayWise = group_by(SalesClientData,Day)
      SalesDayWise = summarize(SalesDayWise,TotalSales = sum(TotalPayRecvdAdj, na.rm=TRUE))
  
      plot_ly(data=SalesDayWise, x = ~Day, y = ~TotalSales, name='Total Sales', type='bar') %&gt;%
        layout(title="Daywise Sales", legend = list(orientation = "h"))
  
    })
  </code></pre>