显示科学计数法 [papaja]
我的代码块中有很多数字:
a <- 1.234 * 10^36
然后我在文档中内联打印:
What does this look like when knitted: `r a`
在标准 .Rmd 中编织它会产生预期的 1.234 x 10^36
但在 papaja 模板中编织会产生“计算格式”与 1.234e+36
无论如何,是否可以自动进行格式化,而不必求助于像 这里给出的解决方案?
I have a large number in my code chunk:
a <- 1.234 * 10^36
Which I then print inline in my document:
What does this look like when knitted: `r a`
Knitting this in a standard .Rmd produces the expected 1.234 x 10^36
But knitting in the papaja template produces the "computational format" with 1.234e+36
Is there anyway to automate the formatting, without having to resort to a custom function like the solution given here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用函数
papaja::apa_num()
:You could use the function
papaja::apa_num()
:您可以使用
knitr
强制格式化。这会将外观格式化为如下所示(已使用如上所述的代码)。
我不喜欢关于
x
的空间分布不均匀,所以我发现捕获了函数(和支持函数)并且能够得到:对于前者,我按照您的指示使用。不过,这不是您将用于第二个选项的内容。
您不需要调用
hooks$set
,但需要调用修改后的函数并使用$
封装该调用。以下是产生第二个选项的稍加修改的 knitr 函数:
或者,您可以在下载的 knitr 包中更改此设置。 (不过,我之前对下载的软件包进行了修改,而不是
knitr
。)仅供参考,这是经过测试的,图像来自 knitted RMD,使用输出设置为
output: papaja ::apa6_pdf
。You can use
knitr
to force formatting.This will format the appearance to look like this (having used your code as described above).
I wasn't fond of the uneven distribution of space about
x
, so I found captured the functions (and supporting functions) and was able to get:For the former, I used as you indicated. This isn't what you would use for the second option, though.
You wouldn't need to call the
hooks$set
, but you would need to call the modified function and encapsulate the call with$
.Here are the slightly modified
knitr
functions that produced the second option:Alternatively, you can change this in your download of the knitr package. (I've made modifications to my downloaded packages before, not
knitr
, though.)FYI, this was tested with and the images were from the knitted RMD using the output set to
output: papaja::apa6_pdf
.