Question: Please help with a code to correctly plot filtered data in R shiny app. I am trying to plot the averages for ALB,ALP,ALT,AST,BIL,CHE,CHOL,CREA,GGT , PROT

Please help with a code to correctly plot filtered data in R shiny app. I am trying to plot the averages for ALB,ALP,ALT,AST,BIL,CHE,CHOL,CREA,GGT,PROT for the selection chosen by the user. For example if the user chose age range 33-35, category= O, and male, I want the barplot to display the averages ALB,ALP,ALT,AST,BIL,CHE,CHOL,CREA,GGT,PROT for age range 33-35, category= O, and male.
ui <- fluidPage( titlePanel("Mo Importnat data"), sidebarLayout( sidebarPanel( sliderInput("range", "Range:", min = min(d1$Age), max = max(d1$Age), step=1,value = c(32,39)), selectInput(inputId = "Cat", "Category:", choices = levels(d1$Category)), radioButtons("S", "Choose Male or Female:", choices = levels(d1$Sex)), ), mainPanel( textOutput("text1"), plotOutput("carPlot"), ) ) ) server <- function(input, output){ output$carPlot <- renderPlot({ plot2<-d1%>% select(Category,Age,Sex,ALB,ALP,ALT,AST,BIL,CHE,CHOL,CREA,GGT,PROT)%>%filter(Category==input$Cat)%>%filter(Sex==input$S)%>%filter(Age>=input$range[1] & Age<=input$range[2]) TAR <- ggplot(tabacouni, aes(x=Year, y=Data_Value,size=Sample_Size)) show(TAR + geom_point(aes(color=Gender))+ scale_x_continuous(name = "Year",breaks=input$range[1]:input$range[2])+ scale_y_continuous(name="Percentages")+ scale_color_manual(values=c("pink","blue","green"))) })

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!