R/read_excel.R

Defines functions read_excel

Documented in read_excel

#' @title read_excel
#'
#' @description Read `.xlsx` (Excel) file.
#'
#' @details Assumes that the first columns stores the row names and the first row the
#' column names.
#'
#' @param filename File name to read from.
#' @param sheet Name of sheet in Excel file.
#' @param dtype Numpy data type.
#'
#' @export
#'
#' @examples
#' \dontrun{
#' ad <- read_excel("spreadsheet.xls")
#' }
read_excel <- function(filename, sheet, dtype = "float32") {
  python_anndata <- reticulate::import("anndata", convert = FALSE)
  filename <- normalizePath(filename, mustWork = FALSE)
  py_to_r_ifneedbe(python_anndata$read_excel(
    filename = filename,
    sheet = sheet,
    dtype = dtype
  ))
}

Try the anndata package in your browser

Any scripts or data that you put into this service are public.

anndata documentation built on March 31, 2023, 10:02 p.m.