From 5a702d328eb1c9f2ad23b0b186e9b676d5f0cc21 Mon Sep 17 00:00:00 2001 From: Jan Marvin Garbuszus Date: Fri, 7 Jul 2023 20:21:55 +0200 Subject: [PATCH] more wb_to_df() to snake_case --- R/readWorkbook.R | 138 +++++++++++++++++++++++------------------------ R/wb_functions.R | 16 +++--- man/read_xlsx.Rd | 40 +++++++------- man/wb_read.Rd | 36 ++++++------- 4 files changed, 115 insertions(+), 115 deletions(-) diff --git a/R/readWorkbook.R b/R/readWorkbook.R index 2c85a91b4..e87e4d88f 100644 --- a/R/readWorkbook.R +++ b/R/readWorkbook.R @@ -1,15 +1,15 @@ #' @name read_xlsx #' @title Read from an Excel file or Workbook object #' @description Read data from an Excel file or Workbook object into a data.frame -#' @param xlsxFile An xlsx file, Workbook object or URL to xlsx file. +#' @param xlsx_file An xlsx file, Workbook object or URL to xlsx file. #' @param sheet The name or index of the sheet to read data from. -#' @param startRow first row to begin looking for data. -#' @param startCol first column to begin looking for data. -#' @param colNames If `TRUE`, the first row of data will be used as column names. -#' @param skipEmptyRows If `TRUE`, empty rows are skipped else empty rows after the first row containing data +#' @param start_row first row to begin looking for data. +#' @param start_col first column to begin looking for data. +#' @param col_names If `TRUE`, the first row of data will be used as column names. +#' @param skip_empty_rows If `TRUE`, empty rows are skipped else empty rows after the first row containing data #' will return a row of NAs. -#' @param rowNames If `TRUE`, first column of data will be used as row names. -#' @param detectDates If `TRUE`, attempt to recognize dates and perform conversion. +#' @param row_names If `TRUE`, first column of data will be used as row names. +#' @param detect_dates If `TRUE`, attempt to recognize dates and perform conversion. #' @param cols A numeric vector specifying which columns in the Excel file to read. #' If NULL, all columns are read. #' @param rows A numeric vector specifying which rows in the Excel file to read. @@ -17,11 +17,11 @@ #' @param check.names logical. If TRUE then the names of the variables in the data frame #' are checked to ensure that they are syntactically valid variable names #' @param sep.names (unimplemented) One character which substitutes blanks in column names. By default, "." -#' @param namedRegion A named region in the Workbook. If not NULL startRow, rows and cols parameters are ignored. +#' @param named_region A named region in the Workbook. If not NULL startRow, rows and cols parameters are ignored. #' @param na.strings A character vector of strings which are to be interpreted as NA. Blank cells will be returned as NA. #' @param na.numbers A numeric vector of digits which are to be interpreted as NA. Blank cells will be returned as NA. -#' @param fillMergedCells If TRUE, the value in a merged cell is given to all cells within the merge. -#' @param skipEmptyCols If `TRUE`, empty columns are skipped. +#' @param fill_merged_cells If TRUE, the value in a merged cell is given to all cells within the merge. +#' @param skip_empty_cols If `TRUE`, empty columns are skipped. #' @param ... additional arguments passed to `wb_to_df()` #' @seealso [wb_get_named_regions()] [wb_to_df()] #' @details Formulae written using write_formula to a Workbook object will not get picked up by read_xlsx(). @@ -34,23 +34,23 @@ #' read_xlsx(xlsxFile = xlsxFile) #' @export read_xlsx <- function( - xlsxFile, + xlsx_file, sheet, - startRow = 1, - startCol = NULL, - rowNames = FALSE, - colNames = TRUE, - skipEmptyRows = FALSE, - skipEmptyCols = FALSE, - rows = NULL, - cols = NULL, - detectDates = TRUE, - namedRegion, - na.strings = "#N/A", - na.numbers = NA, - check.names = FALSE, - sep.names = ".", - fillMergedCells = FALSE, + start_row = 1, + start_col = NULL, + row_names = FALSE, + col_names = TRUE, + skip_empty_rows = FALSE, + skip_empty_cols = FALSE, + rows = NULL, + cols = NULL, + detect_dates = TRUE, + named_region, + na.strings = "#N/A", + na.numbers = NA, + check.names = FALSE, + sep.names = ".", + fill_merged_cells = FALSE, ... ) { @@ -60,21 +60,21 @@ read_xlsx <- function( sheet <- substitute() wb_to_df( - xlsxFile, - sheet = sheet, - startRow = startRow, - startCol = startCol, - rowNames = rowNames, - colNames = colNames, - skipEmptyRows = skipEmptyRows, - skipEmptyCols = skipEmptyCols, - rows = rows, - cols = cols, - detectDates = detectDates, - named_region = namedRegion, - na.strings = na.strings, - na.numbers = na.numbers, - fillMergedCells = fillMergedCells, + xlsx_file, + sheet = sheet, + start_row = start_row, + start_col = start_col, + row_names = row_names, + col_names = col_names, + skip_empty_rows = skip_empty_rows, + skip_empty_cols = skip_empty_cols, + rows = rows, + cols = cols, + detect_dates = detect_dates, + named_region = named_region, + na.strings = na.strings, + na.numbers = na.numbers, + fill_merged_cells = fill_merged_cells, ... ) } @@ -96,20 +96,20 @@ read_xlsx <- function( #' xlsxFile <- system.file("extdata", "openxlsx2_example.xlsx", package = "openxlsx2") #' df1 <- wb_read(xlsxFile = xlsxFile, sheet = 1, rows = c(1, 3, 5), cols = 1:3) wb_read <- function( - xlsxFile, - sheet = 1, - startRow = 1, - startCol = NULL, - rowNames = FALSE, - colNames = TRUE, - skipEmptyRows = FALSE, - skipEmptyCols = FALSE, - rows = NULL, - cols = NULL, - detectDates = TRUE, - namedRegion, - na.strings = "NA", - na.numbers = NA, + xlsx_file, + sheet = 1, + start_row = 1, + start_col = NULL, + row_names = FALSE, + col_names = TRUE, + skip_empty_rows = FALSE, + skip_empty_cols = FALSE, + rows = NULL, + cols = NULL, + detect_dates = TRUE, + named_region, + na.strings = "NA", + na.numbers = NA, ... ) { @@ -119,20 +119,20 @@ wb_read <- function( sheet <- substitute() wb_to_df( - xlsxFile = xlsxFile, - sheet = sheet, - startRow = startRow, - startCol = startCol, - rowNames = rowNames, - colNames = colNames, - skipEmptyRows = skipEmptyRows, - skipEmptyCols = skipEmptyCols, - rows = rows, - cols = cols, - detectDates = detectDates, - named_region = namedRegion, - na.strings = na.strings, - na.numbers = na.numbers, + xlsx_file = xlsx_file, + sheet = sheet, + start_row = start_row, + start_col = start_col, + row_names = row_names, + col_names = col_names, + skip_empty_rows = skip_empty_rows, + skip_empty_cols = skip_empty_cols, + rows = rows, + cols = cols, + detect_dates = detect_dates, + named_region = named_region, + na.strings = na.strings, + na.numbers = na.numbers, ... ) diff --git a/R/wb_functions.R b/R/wb_functions.R index 6f7fa3ad9..697de5971 100644 --- a/R/wb_functions.R +++ b/R/wb_functions.R @@ -683,14 +683,14 @@ wb_to_df <- function( # TODO there probably is a better way in not reducing cc above, so # that we do not have to go through large xlsx files multiple times z_fill <- wb_to_df( - xlsxFile = wb, - sheet = sheet, - dims = filler, - na.strings = na.strings, - convert = FALSE, - colNames = FALSE, - detectDates = detect_dates, - showFormula = show_formula, + xlsx_file = wb, + sheet = sheet, + dims = filler, + na.strings = na.strings, + convert = FALSE, + col_names = FALSE, + detect_dates = detect_dates, + show_formula = show_formula, keep_attributes = TRUE ) diff --git a/man/read_xlsx.Rd b/man/read_xlsx.Rd index a857ec639..1a3bc02ea 100644 --- a/man/read_xlsx.Rd +++ b/man/read_xlsx.Rd @@ -5,43 +5,43 @@ \title{Read from an Excel file or Workbook object} \usage{ read_xlsx( - xlsxFile, + xlsx_file, sheet, - startRow = 1, - startCol = NULL, - rowNames = FALSE, - colNames = TRUE, - skipEmptyRows = FALSE, - skipEmptyCols = FALSE, + start_row = 1, + start_col = NULL, + row_names = FALSE, + col_names = TRUE, + skip_empty_rows = FALSE, + skip_empty_cols = FALSE, rows = NULL, cols = NULL, - detectDates = TRUE, - namedRegion, + detect_dates = TRUE, + named_region, na.strings = "#N/A", na.numbers = NA, check.names = FALSE, sep.names = ".", - fillMergedCells = FALSE, + fill_merged_cells = FALSE, ... ) } \arguments{ -\item{xlsxFile}{An xlsx file, Workbook object or URL to xlsx file.} +\item{xlsx_file}{An xlsx file, Workbook object or URL to xlsx file.} \item{sheet}{The name or index of the sheet to read data from.} -\item{startRow}{first row to begin looking for data.} +\item{start_row}{first row to begin looking for data.} -\item{startCol}{first column to begin looking for data.} +\item{start_col}{first column to begin looking for data.} -\item{rowNames}{If \code{TRUE}, first column of data will be used as row names.} +\item{row_names}{If \code{TRUE}, first column of data will be used as row names.} -\item{colNames}{If \code{TRUE}, the first row of data will be used as column names.} +\item{col_names}{If \code{TRUE}, the first row of data will be used as column names.} -\item{skipEmptyRows}{If \code{TRUE}, empty rows are skipped else empty rows after the first row containing data +\item{skip_empty_rows}{If \code{TRUE}, empty rows are skipped else empty rows after the first row containing data will return a row of NAs.} -\item{skipEmptyCols}{If \code{TRUE}, empty columns are skipped.} +\item{skip_empty_cols}{If \code{TRUE}, empty columns are skipped.} \item{rows}{A numeric vector specifying which rows in the Excel file to read. If NULL, all rows are read.} @@ -49,9 +49,9 @@ If NULL, all rows are read.} \item{cols}{A numeric vector specifying which columns in the Excel file to read. If NULL, all columns are read.} -\item{detectDates}{If \code{TRUE}, attempt to recognize dates and perform conversion.} +\item{detect_dates}{If \code{TRUE}, attempt to recognize dates and perform conversion.} -\item{namedRegion}{A named region in the Workbook. If not NULL startRow, rows and cols parameters are ignored.} +\item{named_region}{A named region in the Workbook. If not NULL startRow, rows and cols parameters are ignored.} \item{na.strings}{A character vector of strings which are to be interpreted as NA. Blank cells will be returned as NA.} @@ -62,7 +62,7 @@ are checked to ensure that they are syntactically valid variable names} \item{sep.names}{(unimplemented) One character which substitutes blanks in column names. By default, "."} -\item{fillMergedCells}{If TRUE, the value in a merged cell is given to all cells within the merge.} +\item{fill_merged_cells}{If TRUE, the value in a merged cell is given to all cells within the merge.} \item{...}{additional arguments passed to \code{wb_to_df()}} } diff --git a/man/wb_read.Rd b/man/wb_read.Rd index e1fd52263..24c8fe6f8 100644 --- a/man/wb_read.Rd +++ b/man/wb_read.Rd @@ -5,40 +5,40 @@ \title{Read from an Excel file or Workbook object} \usage{ wb_read( - xlsxFile, + xlsx_file, sheet = 1, - startRow = 1, - startCol = NULL, - rowNames = FALSE, - colNames = TRUE, - skipEmptyRows = FALSE, - skipEmptyCols = FALSE, + start_row = 1, + start_col = NULL, + row_names = FALSE, + col_names = TRUE, + skip_empty_rows = FALSE, + skip_empty_cols = FALSE, rows = NULL, cols = NULL, - detectDates = TRUE, - namedRegion, + detect_dates = TRUE, + named_region, na.strings = "NA", na.numbers = NA, ... ) } \arguments{ -\item{xlsxFile}{An xlsx file, Workbook object or URL to xlsx file.} +\item{xlsx_file}{An xlsx file, Workbook object or URL to xlsx file.} \item{sheet}{The name or index of the sheet to read data from.} -\item{startRow}{first row to begin looking for data.} +\item{start_row}{first row to begin looking for data.} -\item{startCol}{first column to begin looking for data.} +\item{start_col}{first column to begin looking for data.} -\item{rowNames}{If \code{TRUE}, first column of data will be used as row names.} +\item{row_names}{If \code{TRUE}, first column of data will be used as row names.} -\item{colNames}{If \code{TRUE}, the first row of data will be used as column names.} +\item{col_names}{If \code{TRUE}, the first row of data will be used as column names.} -\item{skipEmptyRows}{If \code{TRUE}, empty rows are skipped else empty rows after the first row containing data +\item{skip_empty_rows}{If \code{TRUE}, empty rows are skipped else empty rows after the first row containing data will return a row of NAs.} -\item{skipEmptyCols}{If \code{TRUE}, empty columns are skipped.} +\item{skip_empty_cols}{If \code{TRUE}, empty columns are skipped.} \item{rows}{A numeric vector specifying which rows in the Excel file to read. If NULL, all rows are read.} @@ -46,9 +46,9 @@ If NULL, all rows are read.} \item{cols}{A numeric vector specifying which columns in the Excel file to read. If NULL, all columns are read.} -\item{detectDates}{If \code{TRUE}, attempt to recognize dates and perform conversion.} +\item{detect_dates}{If \code{TRUE}, attempt to recognize dates and perform conversion.} -\item{namedRegion}{A named region in the Workbook. If not NULL startRow, rows and cols parameters are ignored.} +\item{named_region}{A named region in the Workbook. If not NULL startRow, rows and cols parameters are ignored.} \item{na.strings}{A character vector of strings which are to be interpreted as NA. Blank cells will be returned as NA.}