Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in R Programming by (7.3k points)
edited by

How can I read an Excel file directly into R? Or should I first export the data to a text- or CSV file and import that file into R?

1 Answer

0 votes
by

To read excel files directly, you can use the read_excel function from the readxl package as follows:

#read_excel reads both xls and xlsx files

read_excel("spreadsheet1.xls")

read_excel("spreadsheet2.xlsx")

# Specify sheet with a number or name

read_excel("spreadsheet1.xls", sheet = "data")

read_excel("spreadsheet1.xls", sheet = 2)

# If NAs are represented by something other than blank cells,

# set the na argument

read_excel("spreadsheet1.xls", na = "NA")

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.1k users

Browse Categories

...