R Cheatsheet: Reading XLSX files
#Use the xlsx library
#By default it is not available in base R so we must install package
install.packages("xlsx")
library(xlsx)
#If we use the read.xlsx with only the filename parameter it will cause an error, because we must provide the sheetindex and point out wheter the sheet contains headers for each column
readexcelfile<-function(){ library(xlsx) localcopy<-"./data/cameras.xlsx" cameraXlsx<-read.xlsx(localcopy) head(cameraXlsx) }
#Correct use of read.xlsx
readexcelfile<-function(){ library(xlsx) localcopy<-"./data/cameras.xlsx" cameraXlsx<-read.xlsx(localcopy, sheetIndex = 1, header = TRUE) head(cameraXlsx) }