r - 解析字符中的数值,因为它们与`scipen`的值无关
问题描述
我有一个包含统计测试结果的字符表达式,我想在一个ggplot
对象中解析这个表达式。但是我希望解析后的表达式看起来相同,而不管用户可能为scipen
选项设置的值是什么。
默认scipen = 0
(好)
library(ggplot2)
# plot is just for illustration and has nothing to do with the statistics being displayed
ggplot(mtcars, aes(wt, mpg)) + geom_smooth() + geom_point() +
labs(subtitle = parse(text = "list(~chi['gof']^2~(8)==617.445, ~italic(p)==4.15e-128)"))
与scipen = 999
(不受欢迎的)
library(ggplot2)
options(scipen = 999)
# plot is just for illustration and has nothing to do with the statistics being displayed
ggplot(mtcars, aes(wt, mpg)) + geom_smooth() + geom_point() +
labs(subtitle = parse(text = "list(~chi['gof']^2~(8)==617.445, ~italic(p)==4.15e-128)"))
在不更改用户方面的选项的情况下,如何确保解析的表达式始终采用科学记数法?
解决方案
推荐阅读
- javascript - PWA 使用 Github-Pages 未检测到清单
- java - 字符串 split() 删除尾随的空条目
- wordpress - 编辑或创建新页面(使用块编辑器)和小部件页面 WP 时的空白页面,可能与 wp.blocks 链接
- python - 从```tf.compat.v1.get_default_graph()```可视化每个层或整个图形的输出
- python - 获取使用 Selenium 滚动后出现的其他 HTML 数据
- bazel - 为什么我在编译 Drake 时得到 `fatal error: Eigen/Dense`,即使 `install_prereqs` 成功了?
- javascript - 统计所有用户点击的全局点击计数器
- python - 构建嵌套循环
- java - 在获取 redisson 分布式锁时,是否可以将对象存储在 redis 中以对抗 Lock 键
- python - Selenium python从一个站点更改另一个站点的cookie