问题描述
*编辑以简化示例
我正在尝试使用 apa_table() 为评论论文包含一个包含排除标准的表格。我已经在 excel 中制作了表格,但我正在尝试将 Rstudio 和 Rmarkdown 用于我所有的学术写作。
表格在excel中是这样的
包含 | 排除 | 基本原理 | |
---|---|---|---|
1.出版 | 同行评审期刊 | 同行评审期刊以外的来源(即专业出版物、灰色文献) | 为保证质量... |
2.文章类型 | 研究/实证文章介绍适合分析和综合的方法和结果 | 描述干预措施的文章,但不提供研究结果(即治疗手册) | 评估给定证据... |
3.语言 | 以英文发表或提供的文章 | 英文文章不可用 | 无法使用翻译服务 |
4.节目类型 | 明确针对...的程序 | 不包括......的干预措施 | 确保审核重点... |
我在 python 中更舒服,我认为我可以将 Pandas 数据帧传递给 R 并制作表格,但是当我做时,编织文档显示表格如下:
我也刚刚尝试使用降价文本,结果是......更接近
我使用的代码是
df <- data.frame(inclusion <- c('Peer reviewed Journal articles','Research/Empirical articles presenting methods and results suitable for analysis and synthesis','Articles published or available in English','Programs that explicitly include...'),exclusion <- c('Sources other than peer reviewed journals (i.e. professional publications)','Articles describing interventions without presenting research findings (i.e. theraputuc manuals)','Articles unavailable in English','Interventions that do not include a...'),rationale <- c('To ensure the quality of included...','To evaluate only empirical evidence for a given program/intervention rather than...','No access to translation service','To ensure the review focuses on the outcomes of hero based interventions')
)
rownames(df) <- c('1. Publication type','2. Article type','3. Language','4. Program type')
colnames(df) <- c('Inclusion','Exclusion','Rationale')
library(papaja)
apa_table(
df,caption = "Inclusion/Exclusion Criteria",note = NULL
)
我也通读了this page on the apa_table()
arguments,但运气不佳。任何帮助将不胜感激。
解决方法
在 papaja manual 中,对于这样的情况,有一个有用的技巧:Fixed-width columns
apa_table(
df,caption = "Inclusion/Exclusion Criteria",align = c("p{3cm}",rep("p{3.6cm}",ncol(df))),font_size = "footnotesize"
)
诀窍是通过参数 align
为每列指定一个固定宽度。在这里,我为第一列(您的行名)指定 3cm,为每个适当的列指定 3.6cm(p
表示在每个表格单元格的顶部垂直对齐,但有 other options) .只是为了让整个事情更漂亮,我通过指定 font_size = "footnotesize"
使用较小的字体。
回答以防万一这对我的职位有帮助。
根据上述评论的反馈,我找到了一个适合我需要的解决方案。我敢肯定,更擅长 R 和 LaTex 的人可能会提出比这更好的解决方案,但这对我有用。
我首先运行 apa_table()
函数来查看输出
df <- data.frame(inclusion <- c('Peer reviewed Journal articles','Research/Empirical articles presenting methods and results suitable for analysis and synthesis','Articles published or available in English','Programs that explicitly include...'),exclusion <- c('Sources other than peer reviewed journals (i.e. professional publications)','Articles describing interventions without presenting research findings (i.e. theraputuc manuals)','Articles unavailable in English','Interventions that do not include a...'),rationale <- c('To ensure the quality of included...','To evaluate only empirical evidence for a given program/intervention rather than...','No access to translation service','To ensure the review focuses on the outcomes of hero based interventions')
)
rownames(df) <- c('1. Publication type','2. Article type','3. Language','4. Program type')
colnames(df) <- c('Inclusion','Exclusion','Rationale')
apa_table(
df,note = NULL
)
这会产生输出
"\n\n\n\begin{table}[tbp]\n\n\begin{center}\n\begin{threeparttable}\n\n\caption{test caption}\n\n\begin {tabular}{llll}\n\toprule\n & \multicolumn{1}{c}{inclusion....c..Peer.reviewed.Journal.articles....Research.Empirical.articles.presenting.methods .and.results.suitable.for.analysis.and.synthesis...} & \multicolumn{1}{c}{exclusion....c..Sources.other.than.peer.reviewed.journals..ie .professional.publications....} & \multicolumn{1}{c}{rationale..c..To.ensure.the.quality.of.included..To.evaluate.only .empirical.evidence.for.a.given.program.intervention.rather.than......}\\\n\midrule\n1. 出版物类型和同行评审期刊文章和同行评审期刊以外的来源(即专业出版物)& 确保所包含的质量...\\\n2. 文章类型和研究/经验性文章,展示适合分析和综合的方法和结果,以及描述干预措施的文章,而不展示研究结果(即治疗手册)& 评估只要给定计划/干预的经验证据,而不是......\\\n3.以英文出版或提供的语言和文章以及英文不可用的文章和无法使用翻译服务\\\n4.计划类型 & 明确包括...的计划 & 不包括...的干预 & 确保审查侧重于基于英雄的干预的结果\\\n\bottomrule\n\end{tabular}\n\n \end{threeparttable}\n\end{center}\n\n\end{table}\n\n\n"
然后,我使用 this helpful page 以及对原始问题的评论中提供的资源将该文本墙编辑为 tex
rmarkdown 块
\begin{table}[tbp]
\begin{center}
\begin{threeparttable}
\caption{test caption}
\begin{tabular}{p{4cm} p{4cm} p{4cm} p{4cm}}
\hline
\toprule & \multicolumn{1}{c}{Inclusion} & \multicolumn{1}{c}{Exclusion} & \multicolumn{1}{c}{Rationale}\\
\hline
\midrule 1. Publication type & Peer reviewed Journal articles & Sources other than peer reviewed journals (i.e. professional publications) & To ensure the quality of included...\\
2. Article type & Research/Empirical articles presenting methods and results suitable for analysis and synthesis & Articles describing interventions without presenting research findings (i.e. theraputuc manuals) & To evaluate only empirical evidence for a given program/intervention rather than...\\
3. Language & Articles published or available in English & Articles unavailable in English & No access to translation service\\
4. Program type & Programs that explicitly include... & Interventions that do not include a... & To ensure the review focuses on the outcomes of hero based interventions\\
\bottomrule
\hline
\end{tabular}
\end{threeparttable}
\end{center}
\end{table}
基本上,这只是从字符串输出中删除 unicode 以使其成为 LaTex 代码,然后编辑 Latex 代码以获得所需的输出。
我确信这个答案和问题一样糟糕,但希望它能帮助到那里的人。
[