Artur Guerra
Artur Guerra

Reputation: 85

Interactive ggPredict whitin R Shiny FlexDashboard

I'm using Flexdashboard to create an R Shiny App; for the graph I'm using ggPredict() from ggiraphExtra package

This is the chunk that I need the following plot with a linear regressions using the mtcars dataset:

### Graph2
```{r}

renderPlot({
  Reg_LM <- lm(mpg ~ disp + hp, data = mtcars) 
  ggPredict(Reg_LM, interactive = F)
})

```

When I run my ggPredict with interactive = F my plot runs perfectly!

But when I add interactive = T (for a much better experience) my plot simply disappears (doesnt return any error message)

My guess is that R Shiny doesnt support interactive = T from ggPredict. Could be that? Or FlexDashboard needs another way to handle this?

Thanks!

Upvotes: 1

Views: 199

Answers (1)

Artur Guerra
Artur Guerra

Reputation: 85

Thanks @RyanMorton

Here's the code working perfectly:

### Graph2
```{r}

output$plot5 <- renderggiraph({

  ggiraph(code = print(ggPredict(lm(mpg ~ disp + hp + drat, data = mtcars),
                                 colorAsFactor = T,
                                 point = F)))
})

ggiraphOutput("plot5")


```

Upvotes: 1

Related Questions