Hello all, The following line of code includes a right-to-left language text, yet the R graphics engine displays it from left to right. One problem this causes is when there are parenthesis in the test, here is a basic example? plot(1:10, main = "שלום (טקסט)") Is there a way to make sure the text is displayed from right to left? Many thanks for any suggestions, Tal ----------------Contact Details:------------------------------------------------------- Contact me: Tal.Galili@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) ---------------------------------------------------------------------------------------------- [[alternative HTML version deleted]]
Jean V Adams
2011-Dec-29 22:12 UTC
[R] Is it possible to "right align" text in R graphics?
Tal Galili wrote on 12/29/2011 10:52:55 AM:> Hello all, > > The following line of code includes a right-to-left language text, yetthe> R graphics engine displays it from left to right. One problem thiscauses> is when there are parenthesis in the test, here is a basic example? > > plot(1:10, main = "?? (??)") > > Is there a way to make sure the text is displayed from right to left? > > Many thanks for any suggestions, > Tal > > > ----------------Contact > Details:------------------------------------------------------- > Contact me: Tal.Galili@gmail.com | 972-52-7275845 > Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | > www.r-statistics.com (English) >---------------------------------------------------------------------------------------------- I'm not sure if this is what you're after, but this function reverses the string, character by character and swaps parentheses around. rev.string <- function(x) { revx.indiv <- rev(unlist(strsplit(x, ""))) revx.indiv2 <- revx.indiv revx.indiv2[revx.indiv=="("] <- ")" revx.indiv2[revx.indiv==")"] <- "(" paste(revx.indiv2, collapse="") } plot(1:10, main=rev.string("?? (??)")) Jean [[alternative HTML version deleted]]
Duncan Mackay
2012-Jan-01 03:34 UTC
[R] Is it possible to "right align" text in R graphics?
Hi Tal I think it might be an OS problem whether it is a graphics as well I do not know. I Just copied and pasted the line into R and it seems ok OS win 7 version platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 14.1 year 2011 month 12 day 22 svn rev 57956 language R version.string R version 2.14.1 (2011-12-22) Regards Regards Duncan Mackay Department of Agronomy and Soil Science University of New England ARMIDALE NSW 2351 Email: home mackay at northnet.com.au At 02:52 30/12/2011, you wrote:>Content-Type: text/plain >Content-Disposition: inline >Content-length: 796 > >Hello all, > >The following line of code includes a right-to-left language text, yet the >R graphics engine displays it from left to right. One problem this causes >is when there are parenthesis in the test, here is a basic example? > >plot(1:10, main = "???????? (????????)") > >Is there a way to make sure the text is displayed from right to left? > >Many thanks for any suggestions, >Tal > > >----------------Contact >Details:------------------------------------------------------- >Contact me: Tal.Galili at gmail.com | 972-52-7275845 >Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | >www.r-statistics.com (English) >---------------------------------------------------------------------------------------------- > > [[alternative HTML version deleted]] > > >______________________________________________ >R-help at r-project.org mailing list >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.
Thanks to an e-mail from David, I realized that non-Hebrew speakers will not be able to know how a proper right-to-left output should look like (sorry for not thinking about it myself...) Here is some example code of how the output should look like vs how it currently looks. This is shown only for the main parameter, but the same issue will come up when using ?title or ?text Two points to mention again: 1) This is not a huge problem for me personally, but I believe that in the long term, if such an issue can be fixed, it would have been nice. It will allow all of the right-to-left languages to use R for plotting in their own language (That included, for example, all of the Arabic world... http://en.wikipedia.org/wiki/Right-to-left ). 2) I fear that this type of issue needs to be handled by someone familiar with the guts of the R graphics code. I am not even sure if I should post this here or on the R-devel mailing list. Your advise will be very welcome. Here is the example code: par(mfrow = c(1,2)) plot(1:10, main = "שלום (טקסט)", sub = "The order of text is not right to left") plot(1:10, main = "(שלום (טקסט", sub = "This is how the output should have looked like") # A more complex example: plot(1:10, main = "שלום (טקסט) מידע על Subject 1", sub = "The order of text is not right to left") plot(1:10, main = " Subject 1 שלום (טקסט) מידע על", sub = "This is how the output should have looked like") # An even more complex example: par(mfrow = c(1,1)) plot(1:10, main = "שלום (טקסט) מידע על Subject 1 וגם קצת מידע על subject 2", sub = "The order of text is not right to left") # I am not sure how to fix this actually... Happy new year, Tal ----------------Contact Details:------------------------------------------------------- Contact me: Tal.Galili@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) ---------------------------------------------------------------------------------------------- On Thu, Dec 29, 2011 at 6:52 PM, Tal Galili <tal.galili@gmail.com> wrote:> Hello all, > > The following line of code includes a right-to-left language text, yet the > R graphics engine displays it from left to right. One problem this causes > is when there are parenthesis in the test, here is a basic example? > > plot(1:10, main = "שלום (טקסט)") > > Is there a way to make sure the text is displayed from right to left? > > Many thanks for any suggestions, > Tal > > > ----------------Contact > Details:------------------------------------------------------- > Contact me: Tal.Galili@gmail.com | 972-52-7275845 > Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | > www.r-statistics.com (English) > > ---------------------------------------------------------------------------------------------- > > >[[alternative HTML version deleted]]
Reasonably Related Threads
- Encoding problem - I fails to read Hebrew text from online
- Consistency of variable storage in R and Sys.setlocale (is this a feature or bug)?
- Importing tRNA data into R ?
- How to: highlight R syntax on webpages ?
- How to use read.table with Hebrew column names ?