Rahul H
Rahul H

Reputation: 45

Import specific sheets and specific rows and specific columns from Excel file from readxl package in R

I have a excel file(both xls and xlsx format) with multiple sheets. I have installed readxl package in R. I tried with the below code to import specific sheets, specific rows to columns but getting the error

 install.packages("readxl")
 library("readxl")
 sam1 <- read_excel("File1","Sheet1",rowIndex = 6:8,colIndex = 1:13)

Error in read_excel("File1", "Sheet1", rowIndex = 6:8, : unused arguments (rowIndex = 6:8, colIndex = 1:13)

Can we solve this?

Upvotes: 0

Views: 614

Answers (1)

Gainz
Gainz

Reputation: 1771

You are probably mistaking the readxl package with the xlsx package. Both of them have a read_xlsx() function with different arguments tho.

The result you want can be achieve with the xlsx package. You simply have to install the package :

install.packages("xlsx")
library("xlsx")
sam1 <- read_excel("File1", "Sheet1", rowIndex = 6:8, colIndex = 1:13)

or

sam1 <- xlsx::read_excel("File1", "Sheet1", rowIndex = 6:8, colIndex = 1:13)

Upvotes: 1

Related Questions