r - 如何在 R 中使用 gt() 制作表格?
问题描述
所以,我有这些数据,我正试图将其格式化为一张漂亮的表格。目前,我一直在使用来自 knitr pacakge 的 kable() 命令,但我正在尝试学习如何制作看起来更专业的漂亮表格。我有以下代码:
library(gt)
library(tidyverse)
library(glue)
Player <- c("Russel Westbrook", "James Harden", "Kawhi Leonard", "Lebron James",
"Isaiah Thomas", "Stephen Curry", "Giannis Antetokounmpo", "John Wall",
"Anthony Davis", "Kevin Durant")
Overall_proportion <- c(0.845, 0.847, 0.880, 0.674, 0.909, # q-the ratio of clutch makes
0.898, 0.770, 0.801, 0.802, 0.875) # by clutch attempts
Clutch_makes <- c(64, 72, 55, 27, 75, # Y-values
24, 28, 66, 40, 13)
Clutch_attempts <- c(75, 95, 63, 39, 83, # Clutch_attempts -values
26, 41, 82, 54, 16)
NBA_stats <- as.data.frame(cbind(Player, Overall_proportion, Clutch_makes, Clutch_attempts))
# creating the various quartiles for the posterior distributions
q25 <- qbeta(0.250, Clutch_makes + 1, Clutch_attempts - Clutch_makes + 1)
q50 <- qbeta(0.500, Clutch_makes + 1, Clutch_attempts - Clutch_makes + 1)
q75 <- qbeta(0.750, Clutch_makes + 1, Clutch_attempts - Clutch_makes + 1)
q90 <- qbeta(0.900, Clutch_makes + 1, Clutch_attempts - Clutch_makes + 1)
q_low <- qbeta(0.025, Clutch_makes + 1, Clutch_attempts - Clutch_makes + 1)
q_high <- qbeta(0.975, Clutch_makes + 1, Clutch_attempts - Clutch_makes + 1)
Player_distribution_table <- cbind(q25, q50, q75, q90, q_low, q_high)
rownames(Player_distribution_table) <- Player
我只是想把它变成一个表格,其中行名是玩家的,列名是“25th percentile, 50th percentile”等。
谢谢!
解决方案
推荐阅读
- elm - Unregister multiple subscribers from a given port
- powershell - 使用 powershell 从文本文件中读取内容并将每个单词存储在字符串数组中
- r - 如何从这些数据框中创建子集?
- c++ - 链接器错误:“无法向后移动位置计数器(从 200009f8 到 20000800)”
- python - 在不知道正确的派生类的情况下创建派生类的实例
- ruby-on-rails - 单个 ubuntu 服务器中的多个 rails 应用程序 - 数字海洋
- networking - 如何在 NetLogo 中找到到达目的地的网络加权路径上的下一个海龟?
- html - 使用 XSL 转换定位和格式化包含在 XML 属性中的 HTML
- pip - 无法安装 apache 超集
- python - 如何根据 sale_order_line 中的自定义日期时间字段更新 stock_move 文档中的 date_expected 值