Error in Shiny App

Hello,

I'm building a simple regression model to Shiny and looks like my server code has some errors. My UI is fine but when launching the app, it keeps showing me this error:

"no applicable method for 'svyglm' applied to an object of class "data.frame"

Can someone help me out with this? Thank you and appreciate. My codes as below

place.data <- read.csv("place_data.csv")

server <- function(input, output) {
  model <- reactive({
    
    svyglm(paste("Risk"," ~ ",paste(input$iv1,collapse="+")),family= quasibinomial, place.data)
    
  })
  
  output$regTab <- renderText({
    stargazer(model(), type = "html", dep.var.labels = "Risk Prediction")
  })
  
}
  
           
ui <- shinyUI(fluidPage(tabPanel(
  "Analyzing ACEs",
  headerPanel("ACEs Prediction Model"),
  sidebarLayout(
    position = "right",
    sidebarPanel(
      h2("Build your model"),
      br(),
      checkboxGroupInput(
        "iv1",
        label = "Select any of the independent variables below to calculate your model. You can change your selection at any time.",
        c("Risk"="Risk", 
          "Poverty"="Poverty", 
          "Education"="Education",
          "Unemployment"="Unemployment",
          "Crime"="Crime", 
          "ACEs" = "ACEs"),
        selected = "Risk"
      )
    ),
    
    
    mainPanel(br(),
              tabsetPanel(
                type = "tabs",
                tabPanel(
                  "Regression Table",
                  h3("Table of Regression Coefficients"),
                  HTML('</br>'),
                  tableOutput("regTab"),
                  HTML('</br>'),
                  helpText("Describe the model")
                )
              )
    )
  )
)
)
)



shinyApp(ui = ui, server = server)

Hi! It seems the problem is coming from yout call to svyglm(), specifically from the place.data object you are passing as an argument.

Were you able to fit this model outside your shiny app successfully?

In any case, I would take a look at the reference for the svyglm() function. It seems the arguments that you are passing might be off.


This post was published by an Appsilon team member. Our company can help you get the most out of RShiny and Posit/RStudio products.

Check our open positions here.

Appsilon: Building impactful RShiny Dashboards and providing R coding services.
Appsilon_GIFsmall_whitebg

Aww Thank you Agus for mentioning, I figured it out. I used the function lm instead and it worked ! Thank you so much for your help!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.