R-related: garbled characters when reading Japanese tables in gs_read

Asked 2 years ago, Updated 2 years ago, 36 views

I'm trying to read data containing Japanese in Google Spreadsheet using R's gs_read, but it's garbled (for example, real estate → <U+5186>U+4E0D><U+52D5><U+7523>). Who knows how to resolve this code?

library(googlesheets)
gs_ls()
data<-gs_key("The seat key is here")
data<-gs_read(data)

r

2022-09-30 19:13

1 Answers

The gs_read function in the googlesheets package provides optional arguments for reading text files in the readr package.

Why don't you specify the following argument for locale, which specifies the encoding?Please switch the encoding value according to your operating system.

library(readr)
# windows 
gs_read(data, locale=locale(encoding="cp932"))
# unix series
gs_read(data, locale=locale(encoding="UTF-8")))


2022-09-30 19:13

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.