我正在使用 papaja 在 RMarkdown 中创建一个 APA 格式的文档,但是当我尝试创建我的文档时 apa_tables() 函数会引发错误[旁注:apa_tables() 建立在 kable() 之上]
## reprex dataframe
head<-structure(list(age = c(30, 30, 24, 30, 29, 58),
education = structure(c(5L, 2L, 2L, 2L, 2L, 3L), .Label = c("Less than high school", "High school diploma or GED", "Some college", "Associate's degree", "Bachelor's degree", "Professional or Masters degree", "Doctorate"), class = "factor"),
gender = structure(c(2L, 2L, 2L, 2L, 2L, 1L), .Label = c("Male", "Female", "Non-binary", "Agender", "Androgynous", "Demigirl", "Transgender (preferred gender not stated)","NA"), class = "factor"),
household_income = structure(c(5L, 3L, 6L, 1L, 2L, 2L), .Label = c("Less than $10,000", "$10,000 - $19,999","$20,000 - $29,999", "$30,000 - $39,999", "$40,000 - $49,999", "$50,000 - $59,999", "$60,000 - $69,999", "$70,000 - $79,999", "$80,000 - $89,999", "$90,000 - $99,999", "$100,000 - $149,999", "More than $150,000", "Prefer not to say"), class = "factor"),
ideology_general = c(8L, 3L, 5L, 8L, 9L, 8L),
ideology_economic = c(9L, 6L, 8L, 4L, 9L, 8L),
ideology_social = c(7L, 4L, 3L, 6L, 9L, 8L),
study = c("Climate Change", "Climate Change", "Flu vaccination", "Climate Change", "Climate Change", "Flu vaccination")),
row.names = c(NA,-6L), class = c("tbl_df", "tbl", "data.frame"))
## Use tableone to create a demographics table
tab<-print(tableone::CreateTableOne(vars = c("age",
"education",
"gender",
"household_income",
"ideology_general",
"ideology_economic",
"ideology_social"),
data = head, strata = "study", test = FALSE), printToggle = FALSE)
## print table using papaja
papaja::apa_table(tab)
此代码引发错误
Error in as.data.frame.character(x, stringsAsFactors = FALSE, ...) : formal argument "stringsAsFactors" matched by multiple actual arguments
就行了papaja::apa_table(tab)
如果我使用 knitr::kable(tab) 而不是 papaja::apa_table(tab) 创建表,这确实会按预期运行,但这让我没有其他所需的格式选项。
已解决:升级到新版本的 papaja 解决了这个问题。