数据集
这是我的数据集的输入头:
structure(list(Year = c("2021", "2021", "2021", "2021", "2021",
"2021"), Month_Number = c("9", "9", "9", "9", "9", "9"), Month_Name = c("September",
"September", "September", "September", "September", "September"
), Day_Name = c("Wednesday", "Thursday", "Friday", "Saturday",
"Sunday", "Monday"), Time_Wake = c(500L, 715L, 600L, 600L, 700L,
600L), Mins_Sleep = c(300L, 540L, 540L, 480L, 480L, 480L), Start_Work = c(1015L,
1000L, 945L, 1400L, 1500L, 915L), End_Work = c(1800L, 1600L,
1210L, 1700L, 1515L, 1530L), Workout_Y_N = c("Y", "Y", "Y", "N",
"N", "N"), Time_Workout = c(730L, 730L, 730L, NA, NA, NA), Work_Environment = c("Office",
"Office", "Office", "Home", "Home", "Office"), Coffee_Cups = c(3L,
0L, 2L, 6L, 4L, 5L), Tea_Cups = c(2L, 4L, 2L, 0L, 0L, 2L), Mins_Work = c(435L,
350L, 145L, 135L, 15L, 60L)), row.names = c(NA, 6L), class = "data.frame")
脚本
我正在尝试在我的摘要统计信息上运行一个表格,但在使用 gt 库生成它时遇到问题。这是我的脚本:
library(tidyverse)
library(gt)
library(rstatix)
work %>%
get_summary_stats() %>%
gt() %>%
tab_header(
title = md("The ***productivity*** dataset"),
subtitle = md("Descriptives of five months of data on productivity, consumption, and sleep patterns.")
) %>%
cols_label(
n = md("Cases (N)"),
min = md("Min"),
max = md("Max"),
median = md("Median"),
q1 = md("Q1"),
q3 = md("Q3"),
iqr = md("IQR"),
mad = md("MAD"),
mean = md("Mean"),
sd = md("SD"),
se = md("SE"),
ci = md("CI")
) %>%
opt_align_table_header(align = "center") %>%
tab_source_note(
source_note = md("*Data obtained from local matrix.*")
) %>%
tab_footnote(
footnote = "Not a standardized unit.",
locations = cells_stub(rows ="Coffee_Cups")
)
问题
问题是,虽然这个脚本生成表格,但我无法让脚注工作,因为它不能将“Coffee_Cups”识别为一行。tab_footnote
这是没有命令的样子:
这是它给我的错误,它没有多大帮助:
Error: The following row(s) do not exist in the data: Coffee_Cups
我试过修补其他子命令,tab_footnote
但没有成功运行。我该怎么办?