newbie
newbie

Reputation: 907

How to Encode Thai Characters in R

I have read in the text file using read.table.

group <- read.table("Sample_No2.txt", header = T, sep = ",", stringsAsFactors = F)

When I click on the group variable, it returns characters, which are not in English (It is in Thai language), in weird character (Below figure).

How do I make the software recognize the language ?

enter image description here

Thank you

Upvotes: 1

Views: 3303

Answers (2)

blue_elephant
blue_elephant

Reputation: 1

I want to write a shapefile with some columns that contain only Thai letters. Other columns contain numerical and character data.

I imported a shapefile with columns that contains Thai letters. The Thai letters appear normally.

When I write the file to my hard drive using st_write(my_shapefile,"folder/my_shapefile.shp",delete_layer=TRUE) it only shows ??? in the column that should contain Thai letters. The ??? are shown in QGIS and in R (when importing the shp file again).

I tried: Sys.setlocale(locale = "Thai") It gave me a "Warning: OS reports request to set locale to "Thai" cannot be honored[1]".

Upvotes: 0

you need to set locale to Thai in order to enable reading Thai alphabet

Sys.setlocale(locale = "Thai")

i hope this is an answer you were looking for as everyone else

Upvotes: 1

Related Questions