簡體   English   中英

在 R shiny 中顯示相關表

[英]Display Correlation table in R shiny

我嘗試使用以下代碼顯示相關表(Val1 和 Val2)。 但不確定我在這里做錯了什么。 請求任何人幫助我解決這個問題? 下面是reprex。 我正在嘗試在圖表 A 下顯示相關表

---
title: "Untitled"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    runtime: shiny

---

```{r setup, include=FALSE}
library(flexdashboard)
```

```{r}
df <- structure(list(Cat = structure(1:3, .Label = c("A", "B", "C"), class = "factor"), 
    Val1 = c(1, 4, 6), Val2 = c(4, 7, 2)), class = "data.frame", row.names = c(NA, 
-3L))
```

Column {data-width=650}
-----------------------------------------------------------------------

### Chart A

```{r}
dataTableOutput("t10")
output$t10 <- DT::renderDataTable({
  print(as.data.frame(cor(df[2:3],)))
})
```

通過進行這些小的更改,我能夠讓 output 顯示在flexdashboard中。 如果您在 RStudio 控制台中遇到問題,請嘗試單擊“在瀏覽器中打開”按鈕。 DT只有幾行和幾列時,我有時會注意到奇怪的行為,但不確定這是否與我的機器有關。

```{r}
library(DT)

output$t10 <- DT::renderDataTable({
  datatable(cor(df[2:3],))
})

dataTableOutput("t10")
```

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM