简体   繁体   English

使用xlsx软件包r的文本格式错误

[英]text format errors using xlsx package r

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: 我正在使用R中的xlsx包的read.xlsx()导入一个Excel文件(.xls),但是在文本格式中进行了以下更改:

i) three values in the original excel file (entries are in spanish): Alemán ; i)原始excel文件中的三个值(输入为西班牙语):Alemán; Portugués ; 葡萄牙语; Búlgaro 布加罗

ii) the three R data frame values after read.xlsx(): Alemán ; ii)read.xlsx()之后的三个R数据帧值: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. 我试图控制colClasses,但是唯一的机会是数字或字符。 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! 谢谢!

This is the excel file named (df)i have created as per your variables use XLConnect package

在此处输入图片说明

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM