How to import an Excel File into R ?
Last Updated :
22 Feb, 2023
In this article, we will discuss how to import an excel file in the R Programming Language. There two different types of approaches to import the excel file into the R programming language and those are discussed properly below.
File in use:

Method 1: Using read_excel()
In this approach to import the Excel file in the R, the user needs to call the read_excel() function from readxl library of the R language with the name of the file as the parameter. readxl() package can import both .xlsx and .xls files. This package is pre-installed in R-Studio. With the use of this function, the user will be able to import the Excel file in R.
Syntax: read_excel(filename, sheet, dtype = "float32")
Parameters:
- filename:-File name to read from.
- sheet:-Name of the sheet in Excel file.
- dtype:-Numpy data type.
Returns:
The variable is treated to be a data frame.
Example:
R
library(readxl)
gfg_data=read_excel('Data_gfg.xlsx')
gfg_data
Output:

Method 2: Using inbuilt menu Options of Rstudio
This approach is the easy approach to import the excel file in R compared with the previous one as this is the only approach to import an excel file in R where the user need not type any code in the console to import the excel file. Further, here user just needs to work on the environment window of the studio.
Environment window of the Rstudio:

Steps to import excel file using Dataset option from the environment window of Rstudio:
Step 1: Select the Import Dataset option in the environment window. Here the user needs to select the option to import the dataset from the environment window in Rstudio.

Step 2: Select the option of "From excel" under the import Dataset option. In this step, the user needs to select the option to "from excel" as the file is in the form of excel under the import dataset option to import the excel file.

Step 3: Select the browse option and select the excel file to be imported. Now, under this with the click to the browse option user will be given the choice to select the needed excel file to be imported in R.And then the user need to select the needed excel file to be imported in R.

Step 4: Select the import option and the excel file is successfully imported. Now, in this final step user need to select the import button and this will lead to successful importation of the selected excel file by the user in R.
The user chose the dataset according to their choice means that changing the name of the file and type of sheet. May be there are 2 sheets , he choose 2nd one then he choose the 2nd list with the help of sheet option and in max rows how much rows he wants from the data he put into it. And in  skip box , he skips the rows how much he want. In NA box, he write some value in it , if this value is in the data then it makes as NA.
There is also another method for to import the excel files into R-Studio.
Step 1: Click on file
Step 2: In file, click import dataset then choose from excel.

Similar Reads
How to import an Excel file into Rmarkdown? In this article, we are going to learn how to import excel file into Rmarkdown in R programming language. Excel file is a file where the data is stored in the form of rows and columns. The R markdown is a file where we can embed the code and its documentation in the same file and are able to knit it
2 min read
How to Import a CSV File into R ? A CSV file is used to store contents in a tabular-like format, which is organized in the form of rows and columns. The column values in each row are separated by a delimiter string. The CSV files can be loaded into the working space and worked using both in-built methods and external package imports
3 min read
How to Import .dta Files into R? In this article, we will discuss how to import .dta files in the R Programming Language.There are many types of files that contain datasets, for example, CSV, Excel file, etc. These are used extensively with the R Language to import or export data sets into files. One such format is DAT which is sav
2 min read
How to Import SAS Files into R? In this article, we are going to see how to import SAS files(.sas7bdat) into R Programming Language. SAS stands for Statistical Analysis Software, it contains SAS program code saved in a propriety binary format. The R packages discussed, haven and sas7bdat, involved reverse engineering this proprie
1 min read
How to Import TSV Files into R In this article, we are going to discuss how to import tsv files in R Programming Language. The TSV is an acronym for Tab Separated Values, in R these types of files can be imported using two methods one is by using functions present in readr package and another method is to import the tsv file by
2 min read