簡體   English   中英

在formattable R中格式化表格

[英]Format a table in formattable R

我有一個表格,我正在 R 中繪制,如下所示。 但是我的代碼只為一半的表格生成帶有迷你圖的表格。 還有一種方法可以設置表格顯示的條目數。 我對一頁上的所有 30 行感興趣。

structure(list(Name = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 
2L, 2L, 2L, 2L, 2L), .Label = c("John", "Mary"), class = "factor"), 
    year = c(2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 
    2021L, 2021L, 2021L, 2021L, 2021L), week = c(1L, 2L, 3L, 
    4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L), Total = c(3L, 2L, 0L, 
    0L, 1L, 0L, 3L, 2L, 0L, 0L, 1L, 0L)), class = "data.frame", row.names = c(NA, 
-12L))

My code    
test1 %>% 
      group_by(Name) %>%
      summarise("Weekly_trend" = spk_chr(Total)) %>%
      formattable() %>%
      as.datatable() %>%
      spk_add_deps()

as.datatable()中,您可以添加您希望頁面長度有多大的選項。 在這種情況下,我將頁面長度設置為 30。

full_test %>% 
  group_by(Name) %>%
  summarise("Weekly_trend" = spk_chr(Total)) %>%
  formattable() %>%
  as.datatable(options = list(pageLength = 30)) %>%
  spk_add_deps()

暫無
暫無

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

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