I am trying to create a plot using ggplot
containing unicode characters for points, in particular the ear of rice character (, or U+1F33E). However, this unicode string gives the following Error: invalid \u{xxxx} sequence
. Note that it has to be written as "\u{1f33e}"
in R
, because \u1f33e
contains the unicode for another character for "small greek letter iota with dasia and varia" (ἳ, or U+1F33).
The following (adapted from this post) works for me with another character (U+2620):
library(ggplot2)
df <- read.table(text="x y
1 3
2 4
3 6
4 7 ", header=TRUE)
ggplot(data = df, aes(x, y)) +
geom_text(label="\u2620", size = 10, family = "Arial Unicode MS")
But with the ear of rice, I just get the error.
ggplot(data = df, aes(x, y)) +
geom_text(label="\u{1f33e}", size = 10, family = "Arial Unicode MS")
Error: invalid \u{xxxx} sequence (line 2)
How can I get the ear of rice character in R
? I don't think it is an issue with installed fonts, because I specify the font and according to ear of rice page on fontspace.com, Arial Unicode MS contains the character.
Edit to add R session information
> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: OS X 12.5.1
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggplot2_3.3.2
loaded via a namespace (and not attached):
[1] magrittr_2.0.3 tidyselect_1.1.2 munsell_0.5.0 colorspace_2.0-2
[5] R6_2.5.1 rlang_1.0.2 fansi_1.0.3 blob_1.2.1
[9] dplyr_1.0.8 tools_4.0.2 grid_4.0.2 gtable_0.3.0
[13] utf8_1.2.2 cli_3.3.0 DBI_1.1.0 withr_2.5.0
[17] ellipsis_0.3.2 digest_0.6.29 assertthat_0.2.1 tibble_3.1.6
[21] lifecycle_1.0.1 farver_2.0.3 purrr_0.3.4 vctrs_0.4.1
[25] glue_1.6.2 labeling_0.3 compiler_4.0.2 pillar_1.8.1
[29] generics_0.1.3 scales_1.1.1 pkgconfig_2.0.3
> capabilities()
jpeg png tiff tcltk X11 aqua http/ftp
TRUE TRUE TRUE TRUE TRUE TRUE TRUE
sockets libxml fifo cledit iconv NLS profmem
TRUE TRUE TRUE TRUE TRUE TRUE TRUE
cairo ICU long.double libcurl
TRUE TRUE TRUE TRUE