save_res: A function to save a data frame or a matrix into an Excel...

View source: R/save_res.R

save_resR Documentation

A function to save a data frame or a matrix into an Excel file. Uses openxlsx

Description

Given a 'fileName', create new (wb <- openxlsx::createWorkbook(fileName)) or load existing (wb <- openxlsx::loadWorkbook(fileName)) Excel file. Then, use 'save_res' to save 'res' objects into this file into a specified worksheet. One file can hold multiple worksheets. No need to explicitly close the file.

Usage

save_res(res, fileName = "fileName.xlsx", wb = wb, sheetName = "KEGG")

Arguments

res

a data frame or a matrix to be saved

fileName

a file name with ‘.xlsx' extension to save the results, Default: ’fileName.xlsx'

wb

a workbook object, created initially, Default: wb

sheetName

a name of a worksheet to save the results, Default: 'KEGG'

Value

nothing, just saves the results

Examples

## Not run: 
library(openxlsx)
fileName <- "results/DEGs.xlsx"
unlink(fileName) # Delete previous file
wb <- openxlsx::createWorkbook(fileName) # openxlsx::loadWorkbook(fileName) # Or, load existing
res <- enrichR::enrichFullGeneList(up.genes, dn.genes, databases = "KEGG_2016", fdr.cutoff = 1) # Enrichment analysis of up/downregulated genes
save_res(res, fileName = fileName, wb = wb, sheetName = "KEGG")

## End(Not run)


mdozmorov/MDmisc documentation built on Aug. 24, 2022, 9:18 a.m.