Vikas Singh
Vikas Singh

Reputation: 11

Unable to read Excel file in R-studio

install.packages('read_excel')  
library(xlsx)  
read.xlsx(path, sheet = "C:/Users/Vikas Singh/Desktop/Data KNN.xlsx",sheet=2 , range = NULL, col_names = TRUE, col_types = NULL, na = "", trim_ws = TRUE, skip = 0, n_max = Inf)        

Even after using the above code I'm getting an error message no function read.xlsx

Upvotes: 1

Views: 7386

Answers (2)

Jeniffen
Jeniffen

Reputation: 61

You have to install the openxlsx package. Please read the according documentation here. Try out the following code:

install.packages("openxlsx")
library(openxlsx)  

read.xlsx(xlsxFile = "C:/Users/Vikas Singh/Desktop/DataKNN.xlsx", sheet= <sheet_index> , <... all_your_other_arguments>)

Upvotes: 1

red_quark
red_quark

Reputation: 1001

The read.xlsx is a function from the openxlsx package. You need install and load the readxl package.

install.packages("readxl")
library(readxl)

Then try the following code:

read_excel(path = "C:/Users/Vikas Singh/Desktop/Data KNN.xlsx", sheet = 2, col_names = TRUE, col_types = NULL, na = "", skip = 0)

Upvotes: 1

Related Questions