gpt4 book ai didi

r - extrafont::loadfonts(device = "win") 在 Rprofile 中不起作用,但在控制台中很好

转载 作者:行者123 更新时间:2023-12-05 06:23:32 25 4
gpt4 key购买 nike

我试图按照 Will Chase 的建议将 loadfonts 行放在 .RProfile 文件中,这样我就可以在我通常加载 ggplot2 之前执行。 his advice

不知何故我遇到了这个有趣的现象,当我写:

if(interactive()) 
try(extrafont::loadfonts(device = "win"))

RStudio 报错

Error in get(as.character(FUN), mode = "function", envir = envir) : 
object 'windowsFonts' of mode 'function' was not found

一定是幕后魔术。一旦我 Handlebars 放在控制台上,我就可以运行 extrafont::loadfonts(device = "win") 它将使用 windowsFonts() 向 R 注册字体>.

在解释 .RProfile 时,windowsFonts 函数似乎不可用。不知道为什么,如果能帮助我解决这个问题,我将不胜感激。

最佳答案

回复很晚,但我遇到了同样的问题,并在阅读本文后找到了解决方案。 windowsFonts() 是 grDevices 库中的一个函数。 extrafont 导入 grDevices,但由于某种原因,它在 .Rprofile 中运行时无法识别 - 它必须与 R 加载时的操作顺序有关。如果你加载 grDevices 它会起作用。请参阅下面的代码。

library(extrafont)
loadfonts("win", quiet = F)

Error in get(as.character(FUN), mode = "function", envir = envir) :
object 'windowsFonts' of mode 'function' was not found
Calls: <Anonymous> -> match.fun -> get
Execution halted
library(grDevices)
library(extrafont)
loadfonts("win", quiet = F)
Registering fonts with R

关于r - extrafont::loadfonts(device = "win") 在 Rprofile 中不起作用,但在控制台中很好,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58279537/

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