gpt4 book ai didi

r - ggplot : scales package中的欧元符号

转载 作者:行者123 更新时间:2023-12-04 04:50:23 24 4
gpt4 key购买 nike

我注意到,使用scales包,可以使用轴内的scales = dollar选项(例如scale_y_log10())在轴上显示美元。似乎缺少scales = euro这样的选项。我有一种简单的方法可以达到相同的效果吗?

最佳答案

修改dollar_format并将符号更改为euro很容易。运行它并将其放在代码中,就像调用dollar_format一样

euro_format <- function(largest_with_cents = 100000) {
function(x) {
x <- round_any(x, 0.01)
if (max(x, na.rm = TRUE) < largest_with_cents &
!all(x == floor(x), na.rm = TRUE)) {
nsmall <- 2L
} else {
x <- round_any(x, 1)
nsmall <- 0L
}
str_c("€", format(x, nsmall = nsmall, trim = TRUE, big.mark = ",", scientific = FALSE, digits=1L))
}
}

关于r - ggplot : scales package中的欧元符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11935797/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com