Here is just a simple example of making a R graphic embedded with Chinese characters. For other language, please refer to the aforementioned documentation.
# R code
pdf("c:/Rtest.pdf", height=2, width=2, family="CNS1", version="1.3")
par(mar=c(1, 1 , 1, 1))
matplot(0:2, 0:2, type="n", axes=F, ylab="", xlab="")
box()
text(1, 1, "測試中文")
dev.off()

The crux is that you have do define a font family in your graphic command. For this example, the font family for Chinese is "CNS1." One caveat is that for some language, the version of PDF needed to be 1.3 or above, as shown in this example code.
No comments:
Post a Comment