2016-10-04 46 views
0

我正在使用R通过RODBC软件包导入数据。我使用的Excel文件在表名中带有重音的问题,我需要弄清楚如何导入数据,而无需手动更改电子表格的名称。当表格中有重音字符时用RODBC导入数据

下面是问题的一个重复的例子:

download.file("http://www.secretariadoejecutivo.gob.mx/docs/datos_abiertos/Datos_abiertos_Victimas_Fuero_comun.xls", 
      destfile="./Victimas_Fuero_comun.xls", 
      mode = "wb") 

library(RODBC) 

filePath <- "./Victimas_Fuero_comun.xls" 
channel <- odbcConnectExcel2007(filePath) 
sqlTables(channel) 
DatosAbiertosVictimasFuero <- sqlFetch(channel, 
          "Datos_abiertos_Víctimas_Fuero_c") # accent in 'Víctimas' 
odbcClose(channel) 
str(DatosAbiertosVictimasFuero) 


sessionInfo() 

R version 3.3.0 (2016-05-03) 
Platform: x86_64-w64-mingw32/x64 (64-bit) 
Running under: Windows 7 x64 (build 7601) Service Pack 1 

locale: 
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C        LC_TIME=English_United States.1252  

attached base packages: 
[1] stats  graphics grDevices utils  datasets methods base  

other attached packages: 
[1] RODBC_1.3-13 

回答

0

这个工作

library(readxl) 

filePath <- "./Victimas_Fuero_comun.xls" 


data <- read_excel(filePath, sheet = 1) 
相关问题