在 r markdown 中包装来自 apa_table() 的文本?
wrapping text from apa_table() in r markdown?
*编辑以简化示例
我正在尝试使用 apa_table() 为评论论文包含 table 的包含排除标准。我已经在 excel 中完成了 table,但我正尝试在我所有的学术写作中使用 Rstudio 和 Rmarkdown。
table在excel
中看起来像这样
包容
排除
理由
1。出版物
同行评审期刊
同行评审期刊以外的来源(即专业出版物、灰色文献)
保证质量...
2。文章类型
Research/Empirical 篇介绍方法和结果的文章 table 用于分析和综合
描述干预措施但未呈现研究结果的文章(即治疗手册)
评估给定的证据...
3。语言
以英文发表或可用的文章
英文文章不可用
无法访问翻译服务
4。节目类型
明确针对...的程序
不包括的干预措施......
确保审核重点...
我更喜欢 python 中的 table 并且有了网状结构,我想我可以将 Pandas 数据帧传递给 R 并制作 table,但是当我做编织文档时,显示 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')
library(papaja)
apa_table(
df
, caption = "Inclusion/Exclusion Criteria"
, note = NULL
)
我也通读了 this page on the apa_table()
arguments 但没有任何运气。任何帮助将不胜感激。
回答以防万一这对处于我位置的人有帮助。
根据以上评论的反馈,我找到了适合我需要的解决方案。我敢肯定,更擅长 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
, caption = "Inclusion/Exclusion Criteria"
, note = NULL
)
这会产生输出
"\n\n\n\begin{table}[tbp]\n\n\begin{center}\n\begin{threeparttable}\n\n\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..即..professional.publications..} & \multicolumn{1}{c}{基本原理....c..To.ensure.the.quality.of.included.......To.evaluate.only.empirical.evidence.for.a.given.program.intervention.rather.than......}\\\n\midrule\n1. 出版物类型和同行评审的期刊文章和来源其他高于同行评审期刊(即专业出版物)& 确保收录质量...\\\n2. 文章类型 & Research/Empirical 文章呈现方法和结果 suitable 用于分析和综合 & 文章描述在不提供研究结果的情况下进行干预(即治疗手册)&仅评估给定 program/intervention 的经验证据,而不是...\\\n3. 语言和英文发表或可用的文章和英文不可用的文章和无法访问to t运行slation service\\\n4. 计划类型 & 明确包括...的计划 & 不包括...的干预 & 确保审查 f关注英雄干预的结果\\\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 代码以获得所需的输出。
我确定这个答案和问题一样糟糕,但希望它能帮助那里的人。
[
在papaja manual, there is a helpful trick for cases like this: 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
表示在每个 table 单元格的顶部垂直对齐,但有 other options).为了让整个事情更漂亮,我通过指定 font_size = "footnotesize"
.
使用较小的字体
PDF 文档中的输出如下所示:
*编辑以简化示例
我正在尝试使用 apa_table() 为评论论文包含 table 的包含排除标准。我已经在 excel 中完成了 table,但我正尝试在我所有的学术写作中使用 Rstudio 和 Rmarkdown。
table在excel
中看起来像这样包容 | 排除 | 理由 | |
---|---|---|---|
1。出版物 | 同行评审期刊 | 同行评审期刊以外的来源(即专业出版物、灰色文献) | 保证质量... |
2。文章类型 | Research/Empirical 篇介绍方法和结果的文章 table 用于分析和综合 | 描述干预措施但未呈现研究结果的文章(即治疗手册) | 评估给定的证据... |
3。语言 | 以英文发表或可用的文章 | 英文文章不可用 | 无法访问翻译服务 |
4。节目类型 | 明确针对...的程序 | 不包括的干预措施...... | 确保审核重点... |
我更喜欢 python 中的 table 并且有了网状结构,我想我可以将 Pandas 数据帧传递给 R 并制作 table,但是当我做编织文档时,显示 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')
library(papaja)
apa_table(
df
, caption = "Inclusion/Exclusion Criteria"
, note = NULL
)
我也通读了 this page on the apa_table()
arguments 但没有任何运气。任何帮助将不胜感激。
回答以防万一这对处于我位置的人有帮助。
根据以上评论的反馈,我找到了适合我需要的解决方案。我敢肯定,更擅长 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
, caption = "Inclusion/Exclusion Criteria"
, note = NULL
)
这会产生输出
"\n\n\n\begin{table}[tbp]\n\n\begin{center}\n\begin{threeparttable}\n\n\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..即..professional.publications..} & \multicolumn{1}{c}{基本原理....c..To.ensure.the.quality.of.included.......To.evaluate.only.empirical.evidence.for.a.given.program.intervention.rather.than......}\\\n\midrule\n1. 出版物类型和同行评审的期刊文章和来源其他高于同行评审期刊(即专业出版物)& 确保收录质量...\\\n2. 文章类型 & Research/Empirical 文章呈现方法和结果 suitable 用于分析和综合 & 文章描述在不提供研究结果的情况下进行干预(即治疗手册)&仅评估给定 program/intervention 的经验证据,而不是...\\\n3. 语言和英文发表或可用的文章和英文不可用的文章和无法访问to t运行slation service\\\n4. 计划类型 & 明确包括...的计划 & 不包括...的干预 & 确保审查 f关注英雄干预的结果\\\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 代码以获得所需的输出。
我确定这个答案和问题一样糟糕,但希望它能帮助那里的人。
[
在papaja manual, there is a helpful trick for cases like this: 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
表示在每个 table 单元格的顶部垂直对齐,但有 other options).为了让整个事情更漂亮,我通过指定 font_size = "footnotesize"
.
PDF 文档中的输出如下所示: