[英]wrapping text from apa_table() in r markdown?
*編輯以簡化示例
我正在嘗試使用 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
)
我還通讀了有關apa_table()
參數的此頁面,但沒有任何運氣。 任何幫助,將不勝感激。
在papaja手冊 中,對於這樣的情況,有一個有用的技巧: 固定寬度的列
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
表示在每個表格單元格的頂部垂直對齊,但還有其他選項)。 只是為了讓整個事情更漂亮,我通過指定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
, caption = "Inclusion/Exclusion Criteria"
, 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.出版物....} & \\multicolumn{1}{c}{rationale..c..To.ensure.the.quality.of.included..To.evaluate.only.empirical.證據.for.a.given.program.intervention.rather.than......}\\\\\\n\\midrule\\n1. 出版物類型和同行評審的期刊文章和來源,而不是同行評審的期刊(即專業出版物) & 確保所包含的質量...\\\\\\n2. 文章類型 & 研究/經驗性文章展示適合分析和綜合的方法和結果 & 描述干預的文章而不展示研究結果(即治療手冊) & 僅評估經驗 l 給定計划/干預的證據,而不是......\\\\\\n3. 以英文出版或提供的語言和文章以及英文不可用的文章和無法使用翻譯服務\\\\\\n4. 計划類型 & 明確包括...的計划 & 不包括...的干預 & 確保審查側重於基於英雄的干預的結果\\\\\\n\\bottomrule\\n\\end{tabular}\\n\\n \\end{threeparttable}\\n\\end{center}\\n\\n\\end{table}\\n\\n\\n"
然后我使用這個有用的頁面以及原始問題的評論中提供的資源將該文本牆編輯為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 代碼以獲得所需的輸出。
我確信這個答案和問題一樣糟糕,但希望它可以幫助那里的人。
[
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.