R 和 RStudio 不显示希腊字母和其他符号 - 而是显示方块 [英] R and RStudio don't display greek letters and other symbols - display squares instead
问题描述
我似乎无法在 r 中显示希腊字母.我正在使用 RStudio,无论我尝试什么,我似乎都无法显示希腊字符.最初,我尝试在 bquote
中显示希腊字母,使用的是我所学的课程中的语法,即 prof.发表并证明它在课堂上有效.当它显示的只是正方形**时,我尝试了更基本的希腊字母显示方式.我尝试使用 expression
然后我试图找到最简单的方法并运行我在网上找到的这个语法:
I can't seem to display greek letters in r. I'm working with RStudio, and I can't seem to display greek characters no matter what I try. Initially I tried to display greek letters inside bquote
, using syntax from a class I took, which the prof. published and demonstrated it worked in class. When all it showed was squares**, I tried more basic ways of displaying greek letters. I tried to use expression
and than I tried to find the simplest way and ran this syntax which I found online:
mycoef <- rnorm (1000)
hist(mycoef, main = expression(beta))
在所有情况下,它要么显示一个正方形(如无法识别的符号),要么只显示单词(beta、chi 等).此语法还使用 R 而不是 RStudio 显示一个正方形.
我试图稍微改变文件的编码(ASCII/UTF-8),但这并没有改变任何东西.如果有任何改变,我正在使用 Mac(macOS Sierra 10.12.4).
In all cases it either display a square (like an unrecognized symbol), or just the word (beta, c etc.,). This syntax also displayed a square using R instead of RStudio.
I tried to change a bit the encoding of the file (ASCII/UTF-8), but this didn't change anything. I am working on a mac (macOS Sierra 10.12.4) if that changes anything.
**当使用 bquote
语法时,希腊字母并不是它变成正方形的唯一字符.没有引号的 == 和 ~~ 也显示为正方形.
**when using the bquote
syntax, greek letters were not the only characters it changed to squares. Also == and ~~ without quotes were displayed as squares.
这是我的sessionInfo()
-
R 版本 3.4.2 (2017-09-28)平台:x86_64-apple-darwin15.6.0(64 位)运行于:macOS Sierra 10.12.4
This is my sessionInfo()
-
R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.4
矩阵产品:默认BLAS:/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylibLAPACK:/Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib
Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib
地区:[1] pt_PT.ISO8859-1/pt_PT.ISO8859-1/pt_PT.ISO8859-1/C/pt_PT.ISO8859-1/C
locale: [1] pt_PT.ISO8859-1/pt_PT.ISO8859-1/pt_PT.ISO8859-1/C/pt_PT.ISO8859-1/C
附加基础包:[1] grid stats 图形 grDevices utils datasets 方法基础
attached base packages: [1] grid stats graphics grDevices utils datasets methods base
其他附加包:[1] plyr_1.8.4 meta_4.8-4 openxlsx_4.0.17
other attached packages: [1] plyr_1.8.4 meta_4.8-4 openxlsx_4.0.17
通过命名空间加载(且未附加):[1] compiler_3.4.2 tools_3.4.2 Rcpp_0.12.13
loaded via a namespace (and not attached): [1] compiler_3.4.2 tools_3.4.2 Rcpp_0.12.13
=====
请注意,为了解决此问题,我运行了 sessionInfo 中显示的此语法 - Sys.setlocale("LC_ALL", "pt_PT.ISO8859-1")
,但没有帮助.
=====
Note that as a try to fix this problem I ran this syntax that is displayed in the sessionInfo - Sys.setlocale("LC_ALL", "pt_PT.ISO8859-1")
, which didn't help.
谢谢!
推荐答案
我在 Windows 上更新符号字体解决了这个问题.(1) 下载Symbol.ttf文件(https://www.fontsupply.com/fonts/S/Symbol.html),(2) 在您的\Windows\Fonts 文件夹中找到文件symbol.ttf,并替换为新副本.
I solved this problem updating the Symbols Font on Windows. (1) Download the file Symbol.ttf (https://www.fontsupply.com/fonts/S/Symbol.html), (2) Find the file symbol.ttf in your \Windows\Fonts folder, and replace with the fresh copy.
这篇关于R 和 RStudio 不显示希腊字母和其他符号 - 而是显示方块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!