Friday, August 5, 2016

Myarmar-Sar in R IV: RStudio to the Rescue


Now I run a fragment of the same script I used for my last three posts on Myanmar-Sar in R on my workhorse laptop which doesn't have MyMyanmar Language System installed. Now I run the script on Rstudio and presto!:


And you see that Myanmar-Sar is displayed correctly on the console!

It was not my own brainwave that took me to the right place and sure I know you won't expect me to. It was Yin Zhu's post “Unicode Tips in Python 2 and Rof July 9, 2013 on R-bloggers which I've read some minutes earlier that shows me the key:

Use a Unicode terminal and a Unicode text editor when working with Python and R. For example, RStudio is, while Rgui.exe isn’t. PyDev plugin/PyScripter is, while the default IDLE isn’t.

Case close, at least for dinari.

Immediately after reading Yin Zhu, I installed RStudio. Before, I was just using R's own Rgui and it was fine. Anyway, apart from dinari's problem, another practical need prompted me to try RStudio. It was the need to use Myanmar-Sar (or other non-English characters) as part of the code.

Here let me demonstrate the difficulty and usefulness of the solution involved with a toy example. Let's say a robot from some place in the universe has been recording and sending home the information on living things it “sees” on earth (don't go away; I've translated the data into English for your convenience). Please don't be offended by this extra-terrestrial being's use of Myanmar language. His “dog” category for classifying living things would have meant “others”. I suspect he/she has a Bamar lineage probably from Weitzers and Zawgyis of the ancient past and his/her Myanmar language has gotten rusty.

Now I run this in RStudio:


Note that in the screenshot above we can see Myanmar-Sar correctly for a line in “x” using the cat( ) function. But can't see it in Myanmar-Sar when run in Rgui console as we see in the screenshot below.


But when we write the csv file, both give correct results.


Importantly, this exercise supports our view that not being able to see Myanmar-Sar on the standard R console doesn't diminish R's usefulness for reading, manipulating, and writing Myanmar-Sar in R. However ease of coding involving Myanmar-Sar could be much improved if we use RStudio.

Get a taste of it yourself by trying to write the fifth line of code from the above script shown below by using the standard Rgui console:



Summing up, what I've tried out so far barely scratched the surface of R. Yet I am confident that we could use the power of R in data analysis involving Myanmar-Sar or, I guess, other non-English language as well by using RStudio console together with appropriate R packages. Doing so we have seen that we could use standard Unicode fonts to get our job done without the need for some other fancy or risky software.

No comments:

Post a Comment