xl.read.file

0th

Percentile

Functions for saving and reading data to/from Excel file.

Functions for saving and reading data to/from Excel file.

Usage
xl.read.file(filename, header = TRUE, row.names = NULL, col.names = NULL,
  xl.sheet = NULL, top.left.cell = "A1", na = "", password = NULL,
  write.res.password = NULL, excel.visible = FALSE)

xl.save.file(r.obj, filename, row.names = TRUE, col.names = TRUE, xl.sheet = NULL, top.left.cell = "A1", na = "", password = NULL, write.res.password = NULL, excel.visible = FALSE, file.format = xl.constants$xlOpenXMLWorkbook)

Arguments
filename

a character

header

a logical value indicating whether the file contains the names of the variables as its first line. If TRUE and top-left corner is empty cell, first column is considered as row names. Ignored if row.names or col.names is not NULL.

row.names

a logical value indicating whether the row names of r.obj are to be read/saved along with r.obj

col.names

a logical value indicating whether the column names of r.obj are to be read/saved along with r.obj

xl.sheet

character. Name of Excel sheet where data is located/will be saved. By default it is NULL and data will be read/saved from/to active sheet.

top.left.cell

character. Top-left corner of data in Excel sheet. By default is 'A1'.

na

character. NA representation in Excel. By default it is empty string.

password

character. Password for password-protected workbook.

write.res.password

character. Second password for editing workbook.

excel.visible

a logical value indicating will Excel visible during this operations. FALSE by default.

r.obj

R object.

file.format

integer. Excel file format. By default it is xl.constants$xlOpenXMLWorkbook. You can use xl.constants$xlOpenXMLWorkbookMacroEnabled for workbooks with macros (*.xlsm) or xl.constants$xlExcel12 for binary workbook (.xlsb).

Details

xl.read.file reads only rectangular data set. It is highly recommended to have all column names and ids in data set. Orphaned rows/columns located apart from the main data will be ignored. xl.save.file can save all objects for which xl.write method exists - see examples.

Value

xl.read.file always returns data.frame. xl.save.file invisibly returns NULL.

See Also

xl.write, xl.workbook.save, xl.workbook.open, current.graphics

Aliases
  • xl.read.file
  • xl.save.file
Examples
# NOT RUN {

# }
# NOT RUN {
data(iris)
xl.save.file(iris,"iris.xlsx")
xl.iris = xl.read.file("iris.xlsx")
all(iris == xl.iris) # Shoud be TRUE
unlink("iris.xlsx")

# Save to file list with different data types 
dists = dist(iris[,1:4])
clusters = hclust(dists,method="ward.D")
iris$clusters = cutree(clusters,3)
png("1.png")
plot(clusters)
dev.off()
pl.clus = current.graphics(filename="1.png")
cross = table(iris$Species,iris$clusters)
png("2.png")
plot(cross)
dev.off()
pl.cross = current.graphics(filename="2.png")
output = list("Iris",pl.clus,cross,pl.cross,"Data:","",iris)
xl.save.file(output,"output.xls")
xl.workbook.open("output.xls")
# xl.workbook.close() # close workbook
# unlink("output.xls") # delete file

# password-protected file
data(iris)
xl.save.file(iris,"iris.xlsx", password = "pass")
xl.iris = xl.read.file("iris.xlsx", password = "pass")
all(iris == xl.iris) # Shoud be TRUE
unlink("iris.xlsx")

# }
Documentation reproduced from package excel.link, version 0.9.8-1, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.