heyi xiao
2014-Dec-18 02:25 UTC
[R] Add encoded special characters (greek characters) as text to plot
Dear all, I read my a character matrix from a text file. Some of them have greek characters. To reserve the special characters, I used stringsAsFactors=F using read.table. I notice that I can?t print these character string using print(), but I can use cat():> print("LC\246\302")[1] "LC\246\302"> cat("LC\246\302\n")LC? The problem is when I add text to my output plot like: text(x,y, labels="LC\246\302") I got "LC.. " on my plot. Obviously text function doesn?t know what?s "\246\302". I google that encoding, and can?t find exact what that is. It doesn?t look like ascii or Unicode. Anybody knows what that is? Note that I can?t use expression() method to pass these special characters because these are read from a text file, I just can?t include greek characters manually that way. Is there a way that I can output these strings with special characters automatically? Thank you! Heyi
heyi xiao
2014-Dec-18 16:59 UTC
[R] Add encoded special characters (greek characters) as text to plot
anybody has any hint on this? -------------------------------------------- Subject: Add encoded special characters (greek characters) as text to plot To: r-help at r-project.org Date: Wednesday, December 17, 2014, 9:25 PM Dear all, I read my a character matrix from a text file. Some of them have greek characters. To reserve the special characters, I used stringsAsFactors=F using read.table. I notice that I can?t print these character string using print(), but I can use cat(): > print("LC\246\302") [1] "LC\246\302" > cat("LC\246\302\n") LC? The problem is when I add text to my output plot like: text(x,y, labels="LC\246\302") I got "LC.. " on my plot. Obviously text function doesn?t know what?s "\246\302". I google that encoding, and can?t find exact what that is. It doesn?t look like ascii or Unicode. Anybody knows what that is? Note that I can?t use expression() method to pass these special characters because these are read from a text file, I just can?t include greek characters manually that way. Is there a way that I can output these strings with special characters automatically? Thank you! Heyi
Prof Brian Ripley
2014-Dec-18 17:31 UTC
[R] Add encoded special characters (greek characters) as text to plot
On 18/12/2014 16:59, heyi xiao via R-help wrote:> anybody has any hint on this?Yes, ?plotmath does. But you will need to know what encoding this is (and hence what Unicode points are meant by \246 and \302). If this really were Greek, common encodings are UTF-8, CP1253 and ISO 8859-7; however \246 and \302 are not Greek glyphs in any of those. E.g. > iconv("LC\246\302\n", "cp1253") [1] "LC??\n" (which may not come out in your mail client). BTW, "\246" is explained in ?Quotes.> > -------------------------------------------- > > > Subject: Add encoded special characters (greek characters) as text to plot > To: r-help at r-project.org > Date: Wednesday, December 17, 2014, 9:25 PM > > Dear all, > I read my a character matrix from a text file. Some of them > have greek characters. To reserve the special characters, I > used stringsAsFactors=F using read.table. I notice that I > can?t print these character string using print(), but I > can use cat(): > > print("LC\246\302") > [1] "LC\246\302" > > cat("LC\246\302\n") > LC? > > The problem is when I add text to my output plot like: > text(x,y, labels="LC\246\302") > > I got "LC.. " on my plot. Obviously text function doesn?t > know what?s "\246\302". I google that encoding, and > can?t find exact what that is. It doesn?t look like > ascii or Unicode. Anybody knows what that is? > Note that I can?t use expression() method to pass these > special characters because these are read from a text file, > I just can?t include greek characters manually that way. > Is there a way that I can output these strings with special > characters automatically? > Thank you! > Heyi > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Brian D. Ripley, ripley at stats.ox.ac.uk Emeritus Professor of Applied Statistics, University of Oxford 1 South Parks Road, Oxford OX1 3TG, UK
Jeff Newmiller
2014-Dec-18 17:48 UTC
[R] Add encoded special characters (greek characters) as text to plot
Read the posting guide. The solution is likely to depend on your operating system and graphics devices. --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. On December 18, 2014 8:59:47 AM PST, heyi xiao via R-help <r-help at r-project.org> wrote:>anybody has any hint on this? > >-------------------------------------------- > > >Subject: Add encoded special characters (greek characters) as text to >plot > To: r-help at r-project.org > Date: Wednesday, December 17, 2014, 9:25 PM > > Dear all, > I read my a character matrix from a text file. Some of them > have greek characters. To reserve the special characters, I > used stringsAsFactors=F using read.table. I notice that I > can?t print these character string using print(), but I > can use cat(): > > print("LC\246\302") > [1] "LC\246\302" > > cat("LC\246\302\n") > LC? > > The problem is when I add text to my output plot like: > text(x,y, labels="LC\246\302") > > I got "LC.. " on my plot. Obviously text function doesn?t > know what?s "\246\302". I google that encoding, and > can?t find exact what that is. It doesn?t look like > ascii or Unicode. Anybody knows what that is? > Note that I can?t use expression() method to pass these > special characters because these are read from a text file, > I just can?t include greek characters manually that way. > Is there a way that I can output these strings with special > characters automatically? > Thank you! > Heyi > >______________________________________________ >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code.