R-导入Excel数据

导入2007前的Excel

下载安装RODBC包

1
install.packages("RODBC")

Window 32-bit 导入数据

1
2
3
4
library(RODBC)
channel <- odbcConnectExcel("myfile.xls")
mydataframe <- sqlFetch(channel, "mysheet")
odbcClose(channel)

Window 64-bit 导入数据

1
2
3
4
library(RODBC)
channel <- odbcConnectExcel2007("myfile.xls")
mydataframe <- sqlFetch(channel, "mysheet")
odbcClose(channel)

导入2007 Excel

下载安装xlsx包

1
install.packages("xlsx")

导入数据

1
2
3
4
library(xlsx)
workbook <- "abc.xlsx"
mydataframe <- read.xlsx(workbook, 1)
mydataframe #显示Excel数据

显示导入数据

显示数据