Вот рабочий пример, основанный на вашей идее, с несколькими исправлениями и небольшой помощью от dplyr NSE
#Add stringsAsFactors = FALSE to data.frame to solve ghost factor issue downstream in plotly
df1<-
data.frame (
Vehicle_type=c("CAR","CAR","CAR","MOTORCYCLE","MOTORCYCLE","MOTORCYCLE"),Brand_Name=c("ford","Honda","Audi","SYM","Honda","Harley"),revenues=(as.integer(c("526","552","445","222","223","300"))),cost=(as.integer(c("426","427","325","172","178","235"))),profit=(as.integer(c("100","125","120","50","45","65"))),branch1=(as.integer(c("10","15","12","6","5","5"))),branch2=(as.integer(c("3","4","7","6","4","9"))), stringsAsFactors = FALSE)
shinyServer(function(session,input, output) {
observe({
print(input$ProductId)
#df2<-df1%>%filter(Vehicle_type==input$ProductId) %>% select(Brand_Name)
df2<-df1%>%filter(Vehicle_type==input$ProductId)
#updateSelectInput(session,"nameId","Vehicle Brand Name:",choices=unique(df2))
updateSelectInput(session,"nameId","Vehicle Brand Name:",choices=unique(df2$Brand_Name))
print(input$IndicatorId)
print(df2)
#IndicatorSum<- reactive({df2 %>% pull(input$IndicatorId) %>% sum()})
IndicatorSum<- df2 %>% pull(input$IndicatorId) %>% sum()
print(IndicatorSum)
#browser()
df3<-mutate(df2,!!quo_name(paste0(input$IndicatorId,'_perctcontcl')):=(!!sym(input$IndicatorId)/IndicatorSum)*input$bins)
print(df3)
#To check why we get ghost factor in plotly, we add stringsAsFactors = FALSE to data.frame to solve this issue
print(str(df3))
output$Test2 <- renderPlotly({
Test2 <- plot_ly(
df3, x = ~Brand_Name,
y = ~get(paste0(input$IndicatorId,'_perctcontcl')),
#Here I think you need the updated Indicator after we multiply by input$bin
#y = ~get(input$IndicatorId),
type = "bar",color=~Brand_Name)})
})