绘制 unicode 字符 Windows OS R
Plotting unicode characters Windows OS R
与有关。
在回答链接的问题后,我注意到以下行为:
> '\u226A'
[1] "≪"
但是在尝试绘制相同的符号时,我收到了最漂亮的正方形
plot(1, 1, main = '\u226A')
同时,如果我将它包装在一个空表达式中,它会正确打印符号
plot(1, 1, main = expression('\u226A' ~ ''))
我的问题只是“为什么”它在控制台中有效,在第一个情节中失败而在后者中有效?
> Sys.info()
sysname release version nodename machine
"Windows" "10 x64" "build 19043" "LAPTOP-NGIP5B78" "x86-64"
login user effective_user
"olive" "olive" "olive"
> sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)
Matrix products: default
locale:
[1] LC_COLLATE=English_Denmark.1252 LC_CTYPE=English_Denmark.1252
[3] LC_MONETARY=English_Denmark.1252 LC_NUMERIC=C
[5] LC_TIME=English_Denmark.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.1.0 tools_4.1.0 Rcpp_1.0.6 cellranger_1.1.0 readxl_1.3.1
将编码更改为原生:
a <- '\u226A'
# this shows as a square in R windows console
# but not when posted into browser so I can't easily show it
a
Encoding(a)
## [1] "UTF-8"
b <- enc2native(a)
Encoding(b)
## [1] "latin1"
b
## [1] "«"
还有这些工作:
plot(0, main = ~ '\u226A')
plot(0, main = bquote(.(b)))
与
在回答链接的问题后,我注意到以下行为:
> '\u226A'
[1] "≪"
但是在尝试绘制相同的符号时,我收到了最漂亮的正方形
plot(1, 1, main = '\u226A')
同时,如果我将它包装在一个空表达式中,它会正确打印符号
plot(1, 1, main = expression('\u226A' ~ ''))
我的问题只是“为什么”它在控制台中有效,在第一个情节中失败而在后者中有效?
> Sys.info()
sysname release version nodename machine
"Windows" "10 x64" "build 19043" "LAPTOP-NGIP5B78" "x86-64"
login user effective_user
"olive" "olive" "olive"
> sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)
Matrix products: default
locale:
[1] LC_COLLATE=English_Denmark.1252 LC_CTYPE=English_Denmark.1252
[3] LC_MONETARY=English_Denmark.1252 LC_NUMERIC=C
[5] LC_TIME=English_Denmark.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.1.0 tools_4.1.0 Rcpp_1.0.6 cellranger_1.1.0 readxl_1.3.1
将编码更改为原生:
a <- '\u226A'
# this shows as a square in R windows console
# but not when posted into browser so I can't easily show it
a
Encoding(a)
## [1] "UTF-8"
b <- enc2native(a)
Encoding(b)
## [1] "latin1"
b
## [1] "«"
还有这些工作:
plot(0, main = ~ '\u226A')
plot(0, main = bquote(.(b)))