emacs - R: ESS fails to deal with Thai script variable, but RGui is fine? -
i have code scrapes data website happens in thai script. part of project need replace of thai text. small example follows:
thaidf <- data.frame(thdate = c("31 พฤษภาคม 2555","30 เมษายน 2555"), value = c(100,110)) english_months <- seq(1:12) thai_months <- c('มกราคม','กุมภาพันธ์','มีนาคม','เมษายน','พฤษภาคม','มิถุนายน', 'กรกฎาคม','สิงหาคม','กันยายน','ตุลาคม','พฤศจิกายน','ธันวาคม') print(thaidf) (ii in seq_along(thai_months)) { ## convert months in thai script numerical thaidf$thdate <- (sapply(thaidf$thdate, function(x) {gsub(thai_months[ii], english_months[ii], x, usebytes = true)})) } print(thaidf) when run code inside emacs/ess not work. note how in screenshot below console cannot print thai characters screen when code excecuted, nor can apparently recognise variables in thaidf$thdate, gsub() call not succeed. instead of producing '31 5 2555' 31 day, 5 month , 2555 buddhist year, outputs '311 2555'

however, when copy , paste same code rgui front-end, works fine. both prints characters, shown below, , gsub() correctly replaces thai script latin numbers, 1 expect. can see screengrab below, thai script 'may' becomes '5' , thai script 'april' becomes '4'.

my first thought might font issue, thai fonts seem displayed in emacs buffer, not recognised when code run c-c m-b. why happen? how can prevent it?
sessioninfo() r version 2.15.0 patched (2012-06-03 r59501) platform: i386-pc-mingw32/i386 (32-bit)
locale: 1 lc_collate=english_united kingdom.1252 2 lc_ctype=english_united kingdom.1252
[3] lc_monetary=english_united kingdom.1252 [4] lc_numeric=c
[5] lc_time=english_united kingdom.1252
attached base packages: 1 stats graphics grdevices utils datasets methods base
Comments
Post a Comment