官术网_书友最值得收藏!

Reading in Excel data with the readxl R package

The readxl R package makes it very easy and straightforward to read data from Excel files into R:

We start by loading the module into R:

library(readxl)

Reading Excel data with readxl is simple; we just need to call the read_excel function and pass in the file path, as follows:

read_excel("data.xls")

readxl supports both the old XLS and the new XLSX format. It guesses the format from the extension of the file being read:

read_excel("data.xlsx")

Excel files sometimes have multiple sheets. For example, the following Excel file has multiple sheets:

You can easily handle them with the readxl package. To see the number of sheets in the Excel document, use the excel_sheets command:

excel_sheets("data.xlsx")
#1> [i] "sheet1" "sheet2"

We can also specify which sheet should be accessed by using read_excel with the sheet argument:

read_excel("data.xlsx", sheet= 1)

To access a particular sheet of Excel, the sheet parameter is used: 

read_excel("data.xlsx", sheet= "sheet1")
主站蜘蛛池模板: 民丰县| 青州市| 阿勒泰市| 木里| 沙河市| 拜泉县| 清丰县| 仪征市| 若尔盖县| 仙居县| 柘荣县| 漯河市| 永泰县| 海城市| 东港市| 石泉县| 咸宁市| 湖州市| 图们市| 襄汾县| 武功县| 资源县| 女性| 安远县| 子洲县| 同江市| 正安县| 涟水县| 新闻| 顺义区| 恩平市| 高平市| 文成县| 东兴市| 观塘区| 张家川| 青神县| 福贡县| 博湖县| 梓潼县| 白水县|