Is there a specific server name for ggcorrplot

I am trying ggcorrplot in my server output in R shiny. ggcorrplot is used to create correlation matrix. I tried with renderPlotly. The output is not getting displayed. I am sure its because of this only. When I run ggcorrplot outside R shiny, I am getting the output. Please advice. Or is there an alternate way to create correlation matrix under ggplot only. My Sample data dataframe is like below

install.packages("ggcorrplot")
library(ggcorrplot)
df <- structure(list(Date = structure(c(1L, 1L, 1L, 1L), class = "factor", .Label = "1/1/2010"), 
    Var1 = 12:15, Var2 = 22:25, Var3 = 32:35, Var4 = 42:45), class = "data.frame", row.names = c(NA, 
-4L))

corr <- round(cor(df[2:5]),1)
ggcorrplot(corr,method = "circle",lab = TRUE,hc.order = TRUE)

When I use ggcorrplot under renderploty, there is no output

ggcorrplor() produces a ggplot class object not a plotly object so you have to use renderPlot()

library(shiny)
library(ggcorrplot)

df <- structure(list(Date = structure(c(1L, 1L, 1L, 1L), class = "factor", .Label = "1/1/2010"), 
                     Var1 = 12:15, Var2 = 22:25, Var3 = 32:35, Var4 = 42:45), class = "data.frame", row.names = c(NA, 
                                                                                                                  -4L))

corr <- round(cor(df[2:5]),1)

ui <- plotOutput("plot")

server <- function(input, output) {

    output$plot <- renderPlot({
        ggcorrplot(corr,method = "circle",lab = TRUE,hc.order = TRUE)
    })
}

shinyApp(ui = ui, server = server)

1 Like

Thanks. I agree with you. And I even got this output. The issue is, I have lots of plots that is going inside Renderplotly with only 1 output object.
But, with only one condition I need to incorporate this correlation matrix. Hence I was trying to plot this inside Renderplotly

Sorry I can't understand what you are saying, please provide a minimal reprex to illustrate your actual issue.

1 Like

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