| readOpenxlsx | R Documentation |
Import one or more data.frame from 'Excel' 'xlsx' format
readOpenxlsx(
xlsx,
sheet = NULL,
startRow = 1,
startCol = 1,
rows = NULL,
cols = NULL,
check.names = FALSE,
check_header = FALSE,
check_header_n = 10,
verbose = FALSE,
...
)
xlsx |
|
sheet |
one of |
startRow |
|
startCol |
|
rows |
|
cols |
|
check.names |
|
check_header |
|
check_header_n |
|
verbose |
|
... |
additional arguments are passed to |
This function is equivalent to openxlsx::read.xlsx()
with a few minor additions:
It returns a list of data.frame objects, one per sheet.
It properly reads the colnames with check.names=FALSE.
By default this function returns every sheet for a given
xlsx file.
Some useful details:
Empty columns are not skipped during loading, which means a worksheet whose data starts at column 3 will be returned with two empty columns, followed by data from that worksheet. Similarly, any empty columns in the middle of the data in that worksheet will be included in the output.
When both startRow and rows are applied, rows takes priority
and will be used instead of startRows. In fact startRows will be
defined startRows <- min(rows) for each relevant worksheet. However,
for each worksheet either argument can be NULL.
list of data.frame objects, one per sheet in xlsx.
Other jam export functions:
applyXlsxCategoricalFormat(),
applyXlsxConditionalFormat(),
set_xlsx_colwidths(),
set_xlsx_rowheights(),
writeOpenxlsx()
# set up a test data.frame
set.seed(123);
lfc <- -3:3 + stats::rnorm(7)/3;
colorSub <- nameVector(
rainbow2(7),
LETTERS[1:7])
df <- data.frame(name=LETTERS[1:7],
int=round(4^(1:7)),
num=(1:7)*4-2 + stats::rnorm(7),
fold=2^abs(lfc)*sign(lfc),
lfc=lfc,
pvalue=10^(-1:-7 + stats::rnorm(7)),
hit=sample(c(-1,0,0,1,1), replace=TRUE, size=7));
df;
# write to tempfile for examples
if (check_pkg_installed("openxlsx")) {
out_xlsx <- tempfile(pattern="writeOpenxlsx_", fileext=".xlsx")
writeOpenxlsx(x=df,
file=out_xlsx,
sheetName="jamba_test",
append=FALSE);
# now read it back
df_list <- readOpenxlsx(xlsx=out_xlsx);
df_list[[1]]
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.