Importing .xlsx file with special characters
Asked Answered
C

1

11

I am using the function readWorksheet from the package XLConnect to import Excel sheets in R. These sheets contain special characters (e.g., ø, õ, ú) which R does not handle very well. As far as I know, there is no "encoding" argument for the function readWorksheet as there is for the read.csv one.

Here is what I am doing so far:

data <- readWorksheet(loadWorkbook("data.xlsx"), sheet = 5)

Is there any option I could use to let R know I have special characters?

I am using RStudio 0.99.903 on macOS Sierra 10.12.1.

Camass answered 7/11, 2016 at 10:56 Comment(1)
Could you text xlsx package with: read.xlsx(file = ".xlsx", sheetName = "Arkusz1", encoding = "UTF-8", stringsAsFactors = F)Strigose
S
7

This is UTF-8 letters table http://www.utf8-chartable.de/

I use package xlsx for excel files:

library(xlsx)
read.xlsx(file = ".xlsx", sheetName = "Arkusz1", encoding = "UTF-8", stringsAsFactors = F)

This is in polish language, but print and read.xlsx reads all letters like "ś", "ć" etc.

[27] "Niewłaściwa kwalifikacja memoriałowa przychodu"                                                                                                                                            
[28] "Niewłaściwe ceny transferowe"                                                                                                                                                              
[29] "niewłaściwe zarządzanie relacjami z kontrahentami" 

finally if you can't read xlsx, just save your excel as .csv and read csv with encoding

Strigose answered 7/11, 2016 at 11:34 Comment(1)
Can you add : library(xlsx)?Berth

© 2022 - 2024 — McMap. All rights reserved.