To import excel file, you can use read_excel() function from readxl package.

The following method shows how you can do it with syntax.

Method: Use read.excel() function


df = read_excel("file.xlsx")

The following example shows how to use read_excel() function in R.

Import Excel File Using read_excel() Function

Let’s see example how to import excel file in R:

# Install package

# Import library

# Read data from excel

# print excel data


  Cylinder  Value
  <chr>     <dbl>
1 cylinder1    12
2 cylinder2    10
3 cylinder3    13
4 cylinder4    14

The output shows data from cylinder.xlsx file.

Here we pass excel file name instead of file path to read data from excel file.Also we can see when we print this excel file data it specify datatype of each column.