Here are two ways to import Excel files in R:
- Using read_excel()
- Using the built-in menu Options of Rstudio
Let’s say we have an Excel file like this, and we will import this file in R.
Method 1: Using read_excel()
The easiest method for reading Excel files in R is using the readxl package’s “read_excel()” function. You will need to install this package first if you haven’t already.
To install the readxl package:
install.packages("readxl")
After installing the package, you can use the following code to read an Excel file:
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.
Return value
It is treated as a data frame.
After installing the package, you can use the following code to read an Excel file:
# Load the readxl package
library(readxl)
# Read an Excel file into a data frame
my_data <- read_excel("simple_data_frame.xlsx")
# Display the first few rows of the data
head(my_data)
Output
Method 2: Using the built-in menu Options of Rstudio
If you are using RStudio, you can also use the built-in menu options to import Excel files:
Step 1: Navigate to the Menu Bar
Go to the menu bar at the top and click on File -> Import Dataset -> From Excel.
Step 2: Choose File
A window will pop up. Navigate to the Excel file you wish to import and select it.
Step 3: Preview and Import
You’ll see a preview of the data. If it looks correct, click the Import
button to import the data into R.
Related posts
Read CSV File into DataFrame in R

Krunal Lathiya is a seasoned Computer Science expert with over eight years in the tech industry. He boasts deep knowledge in Data Science and Machine Learning. Versed in Python, JavaScript, PHP, R, and Golang. Skilled in frameworks like Angular and React and platforms such as Node.js. His expertise spans both front-end and back-end development. His proficiency in the Python language stands as a testament to his versatility and commitment to the craft.