tchakravarty
tchakravarty

Reputation: 10954

RStudio and Japanese characters

I am trying to get RStudio to display (using the View function) and to write to CSV (using the write.csv function), Japanese characters that I am reading in from a table.

Here is an example borrowed from this question:

    dfJap = read.table(header = TRUE, sep = ',', text = 'category,desc,otherdesc,volume
    UPC - 31401 Age Itameabura,かどや製油 純白ごま油,OIL_OTHERS_SML_ECO,83.0
    UPC - 31401 Age Itameabura,オレインリッチ,OIL_OTHERS_MED,137.0
    UPC - 31401 Age Itameabura,TVキャノーラ油,OIL_CANOLA_OTHERS_LRG,3026.0', 
fileEncoding = 'ISO-2022-JP')
    View(dfJap)

This shows the output using the UTF-8 enoding rather than the character glyph itself. I wonder if this is an OS issue. My platform is 64-bit Windows 7 Pro.

Here is a session info:

> sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] plyr_1.8        gtools_3.1.1    ggplot2_0.9.3.1

loaded via a namespace (and not attached):
 [1] colorspace_1.2-4   dichromat_2.0-0    digest_0.6.4      
 [4] grid_3.0.1         gtable_0.1.2       labeling_0.2      
 [7] MASS_7.3-26        munsell_0.4.2      proto_0.3-10      
[10] RColorBrewer_1.0-5 reshape2_1.2.2     rstudio_0.98.484  
[13] scales_0.2.3       stringr_0.6.2      tools_3.0.1    

Upvotes: 2

Views: 2917

Answers (1)

shiro
shiro

Reputation: 610

This has been documented as a View() bug in Windows on this post. cat() and print.listof(., locale = locale(encoding = "SJIS")) should display the output correctly.

Upvotes: 2

Related Questions