r - ggcorrplot 是否有特定的服务器名称
问题描述
我在 R 闪亮的服务器输出中尝试 ggcorrplot。ggcorrplot 用于创建相关矩阵。我尝试使用 renderPlotly。输出未显示。我相信它只是因为这个。当我在 R Shiny 之外运行 ggcorrplot 时,我得到了输出。请指教。或者是否有另一种方法可以仅在 ggplot 下创建相关矩阵。我的示例数据数据框如下所示
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时,没有输出
解决方案
你有两个选择:
1)为您的 ggplot 对象使用renderPlot
and
2)将您的 ggplot 对象包装在其中,然后使用and调用。您的里程将非常使用此选项,因为并非 ggplot 的所有美学都被转换为情节。plotOutput
ggploty
renderPlotly
plotlyOutput
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)
推荐阅读
- json - Kotlinx-Serialization 中的映射和变量键名
- rest - 确认 UPS Rate API 测试 URL
- makefile - 我应该如何为 linux 内核模块构建设置额外的包含路径?
- android - 我无法在 android studio 的 ID 中使用自动完成功能
- android-studio - Android:如何从 Google VR SDK 的 VrPanoramaView 中提取和处理位图?
- json - 使用标准 Go unmarshaller 处理非结构化 JSON 数据
- django - 我对 Django REST Filter ID ForeignKey 有疑问
- javascript - 无法将 API 响应保存到窗口对象
- mysql - 查询 if 和 else 语句在 mySQL 中不起作用
- javascript - Javascript 在提交搜索后向 URL 添加排序参数