所以,我有这些数据,我正试图将其格式化为一张漂亮的表格。目前,我一直在使用来自 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”等。
谢谢!