我正在尝试在我的服务器输出中使用R shiny的ggcorrplot。ggcorrplot用于创建相关矩阵。我和renderPlotly试过了。未显示输出。我相信这仅仅是因为这个原因。当我在R shiny外运行ggcorrplot时,我得到了输出。敬请指教。或者只在ggplot下创建相关矩阵的另一种方法。我的示例数据dataframe如下所示
install.packages("ggcorrplot")
library(ggcorrplot)
df
Date Var1 Var2 Var3 Var4
1/1/2019 12 21 34 23
1/1/2019 13 22 35 24
1/1/2019 14 22 35 25
1/1/2019 15 22 35 26
corr <- round(cor(df[2:5]),1)
ggcorrplot(corr,method = "circle",lab = TRUE,hc.order = TRUE)当我在renderploty下使用ggcorrplot时,没有输出
发布于 2019-10-08 21:07:36
您有两个选择:
1)将renderPlot和plotOutput用于您的ggplot对象
2)在ggploty中包装您的ggplot对象,然后使用renderPlotly和plotlyOutput调用。您的里程将非常与此选项,因为并不是所有美学的ggplot被翻译成情节。
library(ggcorrplot)
library(shiny)
library(plotly)
ui <- bootstrapPage(
#numericInput('n', 'Number of obs', n),
plotOutput('plot'),
plotlyOutput('plotly')
)
# Define the server code
server <- function(input, output) {
output$plot <- renderPlot({
cor <- cor(matrix(rnorm(100), ncol = 10))
ggcorrplot(cor)
})
output$plotly <- renderPlotly({
cor <- cor(matrix(rnorm(100), ncol = 10))
ggplotly(ggcorrplot(cor))
})
}
shinyApp(ui, server)https://stackoverflow.com/questions/58285876
复制相似问题