gpt4 book ai didi

r - 如何在 .Rprofile 中设置调色板

转载 作者:行者123 更新时间:2023-12-02 04:41:43 26 4
gpt4 key购买 nike

我想在 R 启动时更改调色板。因此我将以下源代码复制到我的 .Rprofile

palette(c(
"#2e3436" # (Aluminium 6)
, "#ef2929" # (Scarlet Red 1)
, "#73d216" # (Chameleon 2)
, "#3465a4" # (Sky Blue 2)
, "#fcaf3e" # (Orange 1)
, "#ad7fa8" # (Plum 1)
, "#babdb6" # (Butter 1)
, "#babdb6" # (Aluminium 3)
))

启动 R 时会显示以下消息:

Error: Could not fine the function 'palette'

是否无法在启动时更改调色板?

最佳答案

来自 ?Startup

Note that when the site and user profile files are sourced only the 'base' package is loaded, so objects in other packages need to be referred to by e.g. 'utils::dump.frames' or after explicitly loading the package concerned.

因此调用 grDevices::palette() 而不是 palette()。 (需要调用 dev.off() 来消除启动后出现的空白图形窗口。)

grDevices::palette(c(
"#2e3436" # (Aluminium 6)
, "#ef2929" # (Scarlet Red 1)
, "#73d216" # (Chameleon 2)
, "#3465a4" # (Sky Blue 2)
, "#fcaf3e" # (Orange 1)
, "#ad7fa8" # (Plum 1)
, "#babdb6" # (Butter 1)
, "#babdb6" # (Aluminium 3)
))

grDevices::dev.off()

关于r - 如何在 .Rprofile 中设置调色板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20707940/

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