I'm writing a Shiny app that selects a dataframe based on the input in Carrier and performs some functions on it. Here's my code:
library(shiny)
library(ggplot2)
library(dplyr)
library(rlang)
library(shinyWidgets)
library(rstudioapi)
ui <- fluidPage(
  # Give the page a title
  titlePanel("Rate Analysis"),
  # Generate a row with a sidebar
  sidebarLayout(      
    # Define the sidebar with one input
    sidebarPanel(
      selectInput("ProductType","Product Type: (Choose One)",choices=c("t","r")),
      selectInput("inSelect","Carrier: (Choose One)",choices=unique(c(t_rates_names,r_rates_names))),
      selectInput("Category","Category: (Choose One)",choices=c("Age","Term","Band","Class","Gender")),
      sliderInput("discount","% Discount:",min=0,max=100,value=0),
      width=3
    ),
    # Create a spot for the barplot
    mainPanel(
      plotOutput("Minimum_Rates")  
    )
  )
)
server <- function(input, output, session) {
  observe({
    req(input$ProductType)
    x<-sym(input$ProductType)
    updateSelectInput(session,"inSelect",label=paste("test"),choices=eval(parse(text=paste0(x,"_rates_names"))))
  })
  output$Minimum_Rates<-renderPlot({
    req(input$inSelect)
    req(input$Category)
    req(input$discount)
    req(input$ProductType)
    carrier_name<-(input$inSelect)
    carrier<-eval(parse(text=input$inSelect))
    type<-input$ProductType
    category<-sym(input$Category)
    discount<-input$discount
    fee_name=eval(parse(text=paste0(substr(carrier_name,1,nchar(carrier_name)-6),"_fees"))) #gets actual list of fees
    if(type=="t"){
      tMinTable<-removeCarrierRatesAndFindMinimumRates(t_list_rates)
      carrier%>%
      createRatesComparedToTMin(carrier)%>%
      original_percent_higher<-carrier$Percent_Higher%>%
      findRatesFromPrems(carrier,fee_name)%>%
      original_rates<-carrier$`Rates per Thousand`%>%
      discountRatesAndFindNewPrems(carrier,discount/100,fee_name)%>%
      group_by(!!!category) %>%
      summarise(Current_Comparison=sum(original_percent_higher)) %>%
      ggplot(aes_string(input$category,"Current_Comparison"))+geom_bar(stat="identity",position="dodge") + geom_text(aes(label=scales::percent(Current_Comparison)),size=3.2,vjust=-0.5,position=position_dodge(width=1))
    }
    else{
      rMinTable<-removeCarrierRatesAndFindMinimumRates(r_list_rates)
      carrier%>%
      createRatesComparedToRMin(carrier)%>%
      original_percent_higher<-carrier$Percent_Higher%>%
      findRatesFromPrems(carrier,fee_name)%>%
      original_rates<-carrier$`Rates per Thousand`%>%
      discountRatesAndFindNewPrems(carrier,discount/100,fee_name)%>%
      group_by(!!!category) %>%
      summarise(Current_Comparison=sum(original_percent_higher),Hypothetical_Comparison=sum(New_Percent_Higher)) %>%
      ggplot(aes_string(input$category,"Current_Comparison"))+geom_bar(stat="identity",position="dodge") + geom_text(aes(label=scales::percent(Current_Comparison)),size=3.2,vjust=-0.5,position=position_dodge(width=1))
    }
  })
}
shinyApp(ui=ui,server=server)
The error is:
Warning: Error in discountRatesAndFindNewPrems: unused argument (fee_name)
  170: function_list[[i]]
  169: freduce
  168: _fseq
  167: eval
  166: eval
  164: %>%
  163: renderPlot [.../app.R#54]
  161: func
  121: drawPlot
  107: <reactive:plotObj>
   91: drawReactive
   78: origRenderFunc
   77: output$Minimum_Rates
    1: runApp
Unfortunately, I cannot share the data or the functions for legal reasons, but I have tested the functions outside of shiny which worked just fine. The error says I'm not using an argument in the discountRatesAndFindNewPrems function, but the warning points to line #54 which is the carrier%>% line. I'm new to dplyr and shiny in general and cannot understand whether the "%>%" operator can only be used with dplyr functions because I have written another shiny app that used dplyr and the "%>%" operator, but I only used dplyr functions in that app with "%>%". Is there something else I'm missing, such as making Carrier a reactive or something?
 
    