read_excel() method in readxl Package

The Readxl package is used to read data from the excel files i.e. the files of format .xls and .xlsx. The Readxl package provides a function called read_excel() which is used to read the data from excel files. The read_excel() method accepts the excel file which needs to read the content from it. In order to use the read_excel() method, first readxl library needs to be imported. 

Syntax

library(readxl)
data<-read_excel(‘excelFile’,sheet=1)

Parameters

  • excelFile – It specifies the excel file from which we read data.
  • sheet – It specifies from which work sheet we need to read. It is an optional parameter.

Note:- To install the Readxl package in R, use install.packages(“readxl”) command.

Syntax to install and import the readxl package:

install.package('readxl')
library(readxl)

Example: 

Here let’s look into how to read the data from an excel file using read_excel() method present in Readxl package.

Link to the used file:- link

R




# import readxl package
library(readxl)
  
# reading data from an excel file
data <-read_excel('stats.xlsx')  
print(data)


Output:

 Name    Age Runs   Wickets
1 Akhil    21 143    14
2 Mriganka 32 1020   NA
3 Avinash  30 2022   2

Reading and Writing Excel Files With R Using readxl and writexl

In this article let’s discuss reading and writing excel files using readxl and writexl packages of the R programming language.

Similar Reads

read_excel() method in readxl Package:

The Readxl package is used to read data from the excel files i.e. the files of format .xls and .xlsx. The Readxl package provides a function called read_excel() which is used to read the data from excel files. The read_excel() method accepts the excel file which needs to read the content from it. In order to use the read_excel() method, first readxl library needs to be imported....

write_xlsx() method in writexl package:

...

Contact Us