Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 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")

Browse Categories

...