以编程方式在R Console中设置字体和字体大小?

Kar*_* W. 5 windows console user-interface r

是否有可能设置控制台字体和字体大小,我会用"编辑- >首选项界面",以编程方式?这个功能怎么样?我在窗户上.

Jos*_*ien 7

在Windows(至少)上,$R_HOME/etc/Rconsole配置文件为控制台和寻呼机设置了许多可选参数.以下是您可以手动编辑以更改默认字体和字体大小的部分:

## Font.
# Please use only fixed width font.
# If font=FixedFont the system fixed font is used; in this case
# points and style are ignored. If font begins with "TT ", only
# True Type fonts are searched for.
font = TT Courier New
points = 10
style = normal # Style can be normal, bold, italic
Run Code Online (Sandbox Code Playgroud)

要从活动R会话的命令行更改值,可以使用该loadRconsole()功能.它读入包含上面所示形式的指令的文本文件,该文件将覆盖从RconsoleR启动时读取的值.这是一个例子:

temp <- tempfile()
cat("points = 13\n", file = temp)
cat("style = italic\n", file = temp, append = TRUE)
loadRconsole(file = temp)

## And then, to reset to the defaults:
loadRconsole(file = file.path(R.home(), "etc/Rconsole"))
Run Code Online (Sandbox Code Playgroud)