text format errors using xlsx package r

315 views Asked by At

I am importing an excel file (.xls) with read.xlsx() of the xlsx package in R, but I get the following changes in text formats:

i) three values in the original excel file (entries are in spanish): Alemán ; Portugués ; Búlgaro

ii) the three R data frame values after read.xlsx(): Alemán ; Portugués ; Búlgaro

How can I solve this? I´ve tried to control over colClasses but the only chances are numeric or character. The problem seems to be in the control of accents in the spanish language. I want to get the same values without coding for changes after the import. Is that possible? Thanks!

1

There are 1 answers

3
Arun kumar mahesh On
This is the excel file named (df)i have created as per your variables use XLConnect package

enter image description here

library("XLConnect")
> wk=loadWorkbook("df.xls")
> wk=readWorksheet(wk,sheet = "sheet1",startRow = 1)
> wk
  num Alemán. Portugués Búlgaro
1   1 Alemán  Portugués Búlgaro
2   2 Alemán  Portugués Búlgaro
3   3 Alemán  Portugués Búlgaro
4   4 Alemán  Portugués Búlgaro
5   5 Alemán  Portugués Búlgaro
6   6 Alemán  Portugués Búlgaro
7   7 Alemán  Portugués Búlgaro
8   8 Alemán  Portugués Búlgaro