取消R的胶水包中的新行预防
Cancel new line preventions in R's glue package
在胶水包中你"can use \ at the end of a line to prevent adding a newline"。在 LaTeX 中 \\ 是换行符。
我正在寻找比我现在的解决方案更好的解决方案
glue_data(iris,
"\midrule
\textbf{{{mean(Petal.Length)}} & 820 & 100\% \\
~other & 902 \\"
)
实际输出:
\midrule
\textbf{3.758} & 820 & 100\% \~other & 902 \
预期输出:
\midrule
\textbf{3.758} & 820 & 100\% \
~other & 902 \
我目前的丑陋且容易出错的修复:
glue_data(iris,
"\midrule
\textbf{{{mean(iris$Petal.Length)}} & 820 & 100\% \\\
\n~other & 902 \\"
)
\midrule
\textbf{3.758} & 820 & 100\% \
~other & 902 \
我发现一个更好的方法是将 LaTeX 换行符添加为变量以防止它们被 glue
:
解释
lineb <- '\\'
glue_data(
iris,
"\midrule
\textbf{{{mean(Petal.Length)}} & 820 & 100\% {lineb}
~other & 902 \\"
)
输出
\midrule
\textbf{3.758} & 820 & 100\% \
~other & 902 \
在胶水包中你"can use \ at the end of a line to prevent adding a newline"。在 LaTeX 中 \\ 是换行符。
我正在寻找比我现在的解决方案更好的解决方案
glue_data(iris,
"\midrule
\textbf{{{mean(Petal.Length)}} & 820 & 100\% \\
~other & 902 \\"
)
实际输出:
\midrule
\textbf{3.758} & 820 & 100\% \~other & 902 \
预期输出:
\midrule
\textbf{3.758} & 820 & 100\% \
~other & 902 \
我目前的丑陋且容易出错的修复:
glue_data(iris,
"\midrule
\textbf{{{mean(iris$Petal.Length)}} & 820 & 100\% \\\
\n~other & 902 \\"
)
\midrule
\textbf{3.758} & 820 & 100\% \
~other & 902 \
我发现一个更好的方法是将 LaTeX 换行符添加为变量以防止它们被 glue
:
lineb <- '\\'
glue_data(
iris,
"\midrule
\textbf{{{mean(Petal.Length)}} & 820 & 100\% {lineb}
~other & 902 \\"
)
输出
\midrule
\textbf{3.758} & 820 & 100\% \
~other & 902 \