About
xlsx read, write, format Excel 2007 (xlsx) files
Articles Related
Management
Installation
install.packages("xlsx")
package ‘rJava’ successfully unpacked and MD5 sums checked
package ‘xlsxjars’ successfully unpacked and MD5 sums checked
package ‘xlsx’ successfully unpacked and MD5 sums checked
Read
read.xlsx or read.xlsxx
- The read.xlsx function provides the conveniency of read.table by borrowing from its signature.
- The read.xlsx2 function does more work in Java so it achieves better performance (an order of magnitude faster on sheets with 100,000 cells or more).
Return data type: A data.frame or a list, depending on the as.data.frame argument.
require(xlsx)
setwd("path/To/XlsxFile") # Set the working directory
res <- read.xlsx2("data.xlsx", sheetIndex=1, as.data.frame=TRUE, header=TRUE) # read first sheet
head(res)
where:
- colClasses: a character vector that represents the class of each column. Only numeric, character, Date, POSIXct, column types are accepted