R/multi_excel.R

Defines functions multi_excel

Documented in multi_excel

#' multi_excel
#'
#' Read multiple sheets from an excel file
#' @param file Excel file to be read
#' @return A tibble containing data from the excel file
#' @import assertthat
#' @import readxl
#' @examples
#' multi_excel("~/Downloads/abc.xlsx")
#' @export

multi_excel <- function(file) {
  assert_that(is.readable(file))
  assert_that(has_extension(file, "xls") || has_extension(file, "xlsx"))

  all_sheets <- excel_sheets(file)
  result <- lapply(all_sheets, function(sheet) {
    read_excel(file, sheet = sheet)
  })
  return(result)
}
megahf/megahhomework documentation built on May 29, 2019, 4:42 a.m.