以编程方式在R控制台中设置字体和字体大小? [英] Set font and font size in R Console programmatically?

查看:2265
本文介绍了以编程方式在R控制台中设置字体和字体大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以设置控制台字体和字体大小,就像使用编辑 - > GUI首选项,以编程方式?这个函数怎么样?

Is it possible to set the console font and font size, as I would with "Edit->GUI preferences", programmatically? How would a function for this look like? I am on windows.

推荐答案

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

On Windows (at least), the $R_HOME/etc/Rconsole config file sets many optional parameters for the console and pager. Here's the section that you could hand-edit to change the default font and font size:

## 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

要更改活动R会话的命令行中的值,可以使用 loadRconsole()函数。它读入一个包含上面所示形式的指令的文本文件,它将覆盖R启动时从 Rconsole 读取的值。这里有一个例子:

To change the values from the command line of an active R session, you could use the loadRconsole() function. It reads in a text file containing directives of the form shown above, which will overwrite the values read from Rconsole when R was launched. Here's an example:

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"))

这篇关于以编程方式在R控制台中设置字体和字体大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆