From d58b04f91fa8578725dad91808461447d13705ce Mon Sep 17 00:00:00 2001 From: Abel Vertesy Date: Wed, 6 Aug 2025 11:52:41 +0200 Subject: [PATCH 1/6] docs: remove duplicate title --- R/Deprecated.Functions.R | 22 ++--- R/ReadWriter.R | 198 +++++++++++++++++++-------------------- 2 files changed, 108 insertions(+), 112 deletions(-) diff --git a/R/Deprecated.Functions.R b/R/Deprecated.Functions.R index 44b179b..d7ca389 100644 --- a/R/Deprecated.Functions.R +++ b/R/Deprecated.Functions.R @@ -5,13 +5,13 @@ # _________________________________________________________________________________________________ #' @title read.simple.xls -#' @description Read multi-sheet excel files. row_namePos = NULL for automatic -#' names Look into: http://readxl.tidyverse.org/. -#' @param pfn Path and File name, Default: kollapse(...) -#' @param row_namePos Where is the rowname, Default: NULL +#' @description Read multi-sheet Excel files. `row_namePos = NULL` for automatic +#' names. See http://readxl.tidyverse.org/. +#' @param pfn Path and file name. Default: kollapse(...). +#' @param row_namePos Where is the row name? Default: NULL. #' @param ... Multiple simple variables to parse. -#' @param header_ Is there header? Default: TRUE -#' @param WhichSheets Which sheets to read in +#' @param header_ Is there a header? Default: TRUE. +#' @param WhichSheets Which sheets to read. #' @examples #' \dontrun{ #' if (interactive()) { @@ -129,11 +129,11 @@ read.simple.xls <- function(pfn = kollapse(...), row_namePos = NULL, ..., header # _________________________________________________________________________________________________ #' @title convert.tsv.data -#' @description Fix NA issue in dataframes imported by the new read.simple.tsv. -#' Set na_rep to NA if you want to keep NA-s -#' @param df_by_read.simple.tsv Data frame (e.g. by read.simple.tsv). -#' @param digitz Number of digits when rounding up, Default: 2 -#' @param na_rep Replace NA?, Default: 0 +#' @description Fix NA issues in data frames imported by the new read.simple.tsv. +#' Set `na_rep` to NA if you want to keep NAs. +#' @param df_by_read.simple.tsv Data frame (e.g., by `read.simple.tsv`). +#' @param digitz Number of digits when rounding up. Default: 2. +#' @param na_rep Replace NA? Default: 0. #' @seealso #' \code{\link[gtools]{na.replace}} #' @importFrom gtools na.replace diff --git a/R/ReadWriter.R b/R/ReadWriter.R index 4522b01..eaa6826 100644 --- a/R/ReadWriter.R +++ b/R/ReadWriter.R @@ -12,23 +12,23 @@ #' @title Convert a Column to Row Names in a Tibble or DataFrame #' -#' @description Converts the first column (or a specified column) of a dataframe or tibble into row names. -#' This function differs from `tibble::column_to_rownames` in that it takes column names or inices and -#' it offers the option to sanitize row names using `make.names`, provides a warning if there are -#' duplicated values in the row name column +#' @description Converts the first column (or a specified column) of a data frame or tibble into row names. +#' This function differs from `tibble::column_to_rownames` in that it takes column names or indices, +#' offers the option to sanitize row names using `make.names`, and provides a warning if there are +#' duplicated values in the row name column. #' -#' @param tibble A dataframe or tibble without row names. -#' Default: No default value, a dataframe must be provided. +#' @param tibble A data frame or tibble without row names. +#' Default: No default value; a data frame must be provided. #' @param rowname_column Index of the column to be used as row names. #' Default: 1. #' @param make_names Boolean indicating whether to call `make.names` to sanitize row names. #' Default: FALSE. -#' @param as_df Boolean indicating whether to convert the input to a dataframe if it's not already one. +#' @param as_df Boolean indicating whether to convert the input to a data frame if it's not already one. #' Default: TRUE. -#' @param warn Warn user if row names pre-exist. Default: TRUE. +#' @param warn Warn user if row names preexist. Default: TRUE. #' @param overwrite Overwrite row names if they already exist. Default: TRUE. #' -#' @param ... Pass arguments to make.names().. +#' @param ... Pass arguments to `make.names()`. #' @export column.2.row.names <- function(tibble, rowname_column = 1, @@ -100,11 +100,11 @@ column.2.row.names <- function(tibble, rowname_column = 1, # _________________________________________________________________________________________________ #' @title FirstCol2RowNames #' -#' @description Set First Col to Row Names -#' @param Tibble A dataframe without rownames (tibble style) -#' @param rownamecol rowname column, Default: 1 -#' @param make_names call make.names to remove weird characters, Default: FALSE -#' @param as.df Convert tibble to data frame? Default: TRUE +#' @description Set first column to row names. +#' @param Tibble A data frame without row names (tibble style). +#' @param rownamecol Row name column. Default: 1. +#' @param make_names Call `make.names` to remove unusual characters. Default: FALSE. +#' @param as.df Convert tibble to data frame? Default: TRUE. #' @export FirstCol2RowNames <- function(Tibble, rownamecol = 1, make_names = FALSE, as.df = TRUE) { .Deprecated("column.2.row.names") @@ -128,10 +128,10 @@ FirstCol2RowNames <- function(Tibble, rownamecol = 1, make_names = FALSE, as.df # _________________________________________________________________________________________________ #' @title FirstCol2RowNames.as.df -#' @description Set First Col to Row Names -#' @param Tibble A dataframe without rownames (tibble style) -#' @param rownamecol rowname column, Default: 1 -#' @param make_names call make.names to remove weird characters, Default: FALSE +#' @description Set first column to row names. +#' @param Tibble A data frame without row names (tibble style). +#' @param rownamecol Row name column. Default: 1. +#' @param make_names Call `make.names` to remove unusual characters. Default: FALSE. #' @export FirstCol2RowNames.as.df <- function(Tibble, rownamecol = 1, make_names = FALSE) { @@ -155,7 +155,7 @@ FirstCol2RowNames.as.df <- function(Tibble, rownamecol = 1, make_names = FALSE) #' @param extension The file extension to be appended. Default: NULL. #' @param manual_file_name An optional manual specification for the file name. Default: NULL. #' @param manual_directory An optional manual specification for the directory. Default: NULL. -#' @param v verbose Print path? Default: TRUE. +#' @param v Print path if verbose? Default: TRUE. #' #' @return A string representing the constructed file path. #' @importFrom Stringendo sppp ParseFullFilePath @@ -204,8 +204,7 @@ construct.file.path <- function( # _________________________________________________________________________________________________ #' @title read.simple.vec -#' @description read.simple.vec -#' @description Read each line of a file to an element of a vector (read in new-line separated values, no header!). +#' @description Read each line of a file to an element of a vector (read in newline-separated values, no header!). #' @param ... Multiple simple variables to parse. #' @examples #' \dontrun{ @@ -224,7 +223,7 @@ read.simple.vec <- function(...) { # _________________________________________________________________________________________________ #' @title read.simple -#' @description It is essentially read.table() with file/path parsing. +#' @description Essentially `read.table()` with file/path parsing. #' @param ... Multiple simple variables to parse. #' @examples #' \dontrun{ @@ -262,12 +261,12 @@ read.simple_char_list <- function(...) { # _________________________________________________________________________________________________ #' @title read.simple.table -#' @description Read in a file. default: header defines colnames, no rownames. -#' For rownames give the col nr. with rownames, eg. 1 The header should start -#' with a TAB / First column name should be empty. +#' @description Read a file. Default: header defines column names, no row names. +#' For row names give the column number with row names, e.g., 1. The header should start +#' with a TAB; the first column name should be empty. #' @param ... Multiple simple variables to parse. -#' @param colnames Are there column names? Default: TRUE -#' @param coltypes What type of variables are in columns? Auto-guessing can be very slow. Default: NULL +#' @param colnames Are there column names? Default: TRUE. +#' @param coltypes What type of variables are in columns? Auto-guessing can be very slow. Default: NULL. #' @examples #' \dontrun{ #' if (interactive()) { @@ -293,16 +292,16 @@ read.simple.table <- function(..., colnames = TRUE, coltypes = NULL) { # _________________________________________________________________________________________________ #' @title read.simple.tsv -#' @description Read in a file with excel style data: rownames in col1, -#' headers SHIFTED. The header should start with a TAB / First column name +#' @description Read in a file with Excel-style data: row names in column 1, +#' headers shifted. The header should start with a TAB; the first column name #' should be empty. #' @param ... Multiple simple variables to parse. -#' @param sep_ Separator character, Default: ' ' -#' @param colnames Are there column names?, Default: TRUE -#' @param wRownames With rownames?, Default: TRUE -#' @param coltypes What type of variables are in columns? Auto-guessing can be very slow., Default: NULL -#' @param NaReplace Replace NA-values?, Default: TRUE -#' @param asTibble Load as tibble or dataframe?, Default: FALSE (=load as df) +#' @param sep_ Separator character. Default: '\\t'. +#' @param colnames Are there column names? Default: TRUE. +#' @param wRownames With row names? Default: TRUE. +#' @param coltypes What type of variables are in columns? Auto-guessing can be very slow. Default: NULL. +#' @param NaReplace Replace NA values? Default: TRUE. +#' @param asTibble Load as tibble or data frame? Default: FALSE (load as data frame). #' @examples #' \dontrun{ #' if (interactive()) { @@ -338,16 +337,16 @@ read.simple.tsv <- function( # _________________________________________________________________________________________________ #' @title read.simple.csv -#' @description Read in a file with excel style data: rownames in col1, -#' headers SHIFTED. The header should start with a TAB / First column name +#' @description Read in a file with Excel-style data: row names in column 1, +#' headers shifted. The header should start with a TAB; the first column name #' should be empty. #' @param ... Multiple simple variables to parse. -#' @param colnames Are there column names?, Default: TRUE -#' @param coltypes What type of variables are in columns? Auto-guessing can be very slow., Default: NULL -#' @param wRownames With rownames?, Default: TRUE -#' @param NaReplace Replace NA-values?, Default: TRUE -#' @param asTibble Load as tibble or dataframe?, Default: FALSE (=load as df) -#' @param nmax Max number of rows to read, Default: Inf +#' @param colnames Are there column names? Default: TRUE. +#' @param coltypes What type of variables are in columns? Auto-guessing can be very slow. Default: NULL. +#' @param wRownames With row names? Default: TRUE. +#' @param NaReplace Replace NA values? Default: TRUE. +#' @param asTibble Load as tibble or data frame? Default: FALSE (load as data frame). +#' @param nmax Max number of rows to read. Default: Inf. #' @examples #' \dontrun{ #' if (interactive()) { @@ -385,17 +384,16 @@ read.simple.csv <- function( # _________________________________________________________________________________________________ #' @title read.simple.csv.named.vector #' -#' @description Read in a data frame (csv), and extact a value and a name column, and convert them -#' to a named vector. By default, it assumes the names in the first column and the values -#' excel style named vectors, names in col1, -#' headers SHIFTED. The header should start with a TAB / First column name -#' should be empty. +#' @description Read in a data frame (CSV), extract a value and a name column, and convert them +#' to a named vector. By default, it assumes the names are in the first column and the values in the second. +#' For Excel-style named vectors, names are in column 1 and headers are shifted. +#' The header should start with a TAB; the first column name should be empty. #' @param file Path to the *.csv file. -#' @param sep Separator character, Default: ';' alternative: ','. -#' @param col_names Are there column names?, Default: TRUE -#' @param value_col Column number of the values in the input data frame. Default: 2 -#' @param name_col Column number of the names in the input data frame. Default: 1 -#' @param ... Additional arguments passed to \code{\link[readr]{read_csv}} or read_csv2. +#' @param sep Separator character. Default: ';'; alternative: ','. +#' @param col_names Are there column names? Default: TRUE. +#' @param value_col Column number of the values in the input data frame. Default: 2. +#' @param name_col Column number of the names in the input data frame. Default: 1. +#' @param ... Additional arguments passed to \code{\link[readr]{read_csv}} or `read_csv2`. #' @examples #' \dontrun{ #' if (interactive()) { @@ -430,15 +428,15 @@ read.simple.csv.named.vector <- function(file, sep = ";", col_names = FALSE, # _________________________________________________________________________________________________ #' @title read.simple.ssv -#' @description Space separeted values. Read in a file with excel style data: -#' rownames in col1, headers SHIFTED. The header should start with a -#' TAB / First column name should be empty. +#' @description Space separated values. Read in a file with Excel-style data: +#' row names in column 1, headers shifted. The header should start with a +#' TAB; the first column name should be empty. #' @param ... Multiple simple variables to parse. -#' @param sep_ Separator character, Default: ' ' -#' @param colnames Are there column names?, Default: TRUE -#' @param wRownames With rownames?, Default: TRUE -#' @param NaReplace Replace NA-values?, Default: TRUE -#' @param coltypes What type of variables are in columns? Auto-guessing can be very slow., Default: NULL +#' @param sep_ Separator character. Default: ' '. +#' @param colnames Are there column names? Default: TRUE. +#' @param wRownames With row names? Default: TRUE. +#' @param NaReplace Replace NA values? Default: TRUE. +#' @param coltypes What type of variables are in columns? Auto-guessing can be very slow. Default: NULL. #' @examples #' \dontrun{ #' if (interactive()) { @@ -470,8 +468,8 @@ read.simple.ssv <- function( # _________________________________________________________________________________________________ #' @title read.simple.tsv.named.vector -#' @description Read in a file with excel style named vectors, names in col1, -#' headers SHIFTED. The header should start with a TAB / First column name +#' @description Read in a file with Excel-style named vectors, names in column 1, +#' headers shifted. The header should start with a TAB; the first column name #' should be empty. #' @param ... Multiple simple variables to parse. #' @examples @@ -501,7 +499,7 @@ read.simple.tsv.named.vector <- function(...) { #' @title Read a multi-sheet XLSX easily #' #' @description Reads specified sheets from an XLSX file into a list of data frames. -#' It allows customization of column names, row names, and trimming of white spaces. +#' It allows customization of column names, row names, and trimming of whitespace. #' #' @param pfn Path and filename of the XLSX file. #' Default: Constructed using `Stringendo::kollapse(...)`. @@ -509,10 +507,10 @@ read.simple.tsv.named.vector <- function(...) { #' Default: All sheets. #' @param col_names Logical, whether to use the first row as column names. #' Default: TRUE. -#' @param row_names Numeric, whether to convert a column to row names. -#' Default: 1. Use 0 for no conversion. Default: FALSE. -#' @param trim_ws Logical, whether to trim white spaces from column names. -#' @param ... Pass arguments to read.xlsx(). +#' @param row_names Numeric indicating which column to convert to row names. +#' Use 0 or FALSE for no conversion. Default: FALSE. +#' @param trim_ws Logical, whether to trim whitespace from column names. +#' @param ... Pass arguments to `read.xlsx()`. #' #' @return A list of data frames, each representing a sheet from the XLSX file. #' @importFrom openxlsx read.xlsx getSheetNames @@ -569,9 +567,9 @@ read.simple.xlsx <- function( # ____________________________________________________________________________________________ ---- ## Writing files out ------------------------------------------------------------------------------ -#' @title Append or write a vector to standard file, one element per line. +#' @title Append or write a vector to a standard file, one element per line. #' -#' @description Alternative to clipboard. This function takes a vector and appends it +#' @description Alternative to the clipboard. This function takes a vector and appends it #' to a specified file. #' #' @param vec A vector to be written to the file. Default: `LETTERS[1:11]`. @@ -637,7 +635,7 @@ write.simplest <- function(vec = LETTERS[1:11], append = TRUE, header = NULL, pr #' @param manual_file_name Manually defined filename, overrides automatic naming. Default: NULL. #' @param manual_directory Directory to save the file in, overrides default directory. Default: NULL. #' @param o If TRUE, opens the file after writing on OS X using 'system(open ...)'. Default: FALSE. -#' @param v verbose Print path? Default: TRUE. +#' @param v Print path if verbose? Default: TRUE. #' @return Outputs a .tsv file and optionally prints the length of the input data frame. #' @examples #' \dontrun{ @@ -680,7 +678,7 @@ write.simple <- function(input_df, filename = substitute(input_df), suffix = NUL # _________________________________________________________________________________________________ #' @title Write Simple Vector #' -#' @description Writes a vector-like R object to a file as newline separated values (.vec). +#' @description Writes a vector-like R object to a file as newline-separated values (.vec). #' The output filename can be auto-generated from the variable's name or manually specified. The file #' is saved in the specified output directory or the current working directory. The path and variable #' name can be passed separately and will be concatenated to form the filename. @@ -691,7 +689,7 @@ write.simple <- function(input_df, filename = substitute(input_df), suffix = NUL #' @param manual_file_name Manually defined filename, overrides automatic naming. Default: NULL. #' @param manual_directory Directory to save the file in, overrides default directory. Default: NULL. #' @param o If TRUE, opens the file after writing on OS X using 'system(open ...)'. Default: FALSE. -#' @param v verbose Print path? Default: TRUE. +#' @param v Print path if verbose? Default: TRUE. #' #' @return Outputs a .vec file and optionally prints the length of the input vector. #' @examples @@ -736,26 +734,25 @@ write.simple.vec <- function(input_vec, filename = substitute(input_vec), suffix # _________________________________________________________________________________________________ #' @title write.simple.tsv #' -#' @description Write out a matrix-like R-object WITH ROW- AND COLUMN- NAMES to a file with as tab separated -#' values (.tsv). Your output filename will be either the variable's name. The output file will be -#' located in "OutDir" specified by you at the beginning of the script, or under your current -#' working directory. You can pass the PATH and VARIABLE separately (in order), they will be -#' concatenated to the filename. If col.names = NA and row.names = TRUE a blank column name is added, +#' @description Write out a matrix-like R object with row and column names to a file as tab-separated +#' values (.tsv). The output filename will be either the variable's name or the one you provide. The output +#' file will be located in the directory specified at the beginning of the script or in your current +#' working directory. You can pass the path and variable separately (in order); they will be concatenated +#' to the filename. If `col.names = NA` and `row.names = TRUE`, a blank column name is added, #' which is the convention used for CSV files to be read by spreadsheets. -#' @param input_df Your Dataframe with row- and column-names -#' @param ... Pass any other argument to the kollapse() function used for file name. -#' @param separator Field separator, such as "," for csv -#' @param filename The base name for the output file. Default: Name of the input vector. -#' @param extension e.g.: tsv -#' @param suffix A suffix added to the filename, Default: NULL -#' @param manual_file_name Specify full filename if you do not want to name it by the variable name. +#' @param input_df Your data frame with row and column names. +#' @param separator Field separator, such as ',' for CSV. +#' @param filename The base name for the output file. Default: Name of the input data frame. +#' @param extension e.g., 'tsv'. +#' @param suffix A suffix added to the filename. Default: NULL. +#' @param manual_file_name Specify full filename if you do not want to name it after the variable. #' @param manual_directory Specify the directory where the file should be saved. -#' @param row_names Write row names? TRUE by default -#' @param col_names Write column names? NA by default, TRUE if row_names == FALSE -#' @param gzip Compress the file after saving? FALSE by default -#' @param o Open the file after saving? FALSE by default -#' @param v verbose Print path? Default: TRUE. -#' @param ... Additional arguments passed to write.table() +#' @param row_names Write row names? Default: TRUE. +#' @param col_names Write column names? Default: NA, set to TRUE if `row_names == FALSE`. +#' @param gzip Compress the file after saving? Default: FALSE. +#' @param o Open the file after saving? Default: FALSE. +#' @param v Print path if verbose? Default: TRUE. +#' @param ... Additional arguments passed to the kollapse() function used for the file name and to `write.table()`. #' #' @examples YourDataFrameWithRowAndColumnNames <- cbind("A" = rnorm(100), "B" = rpois(100, 8)) #' rownames(YourDataFrameWithRowAndColumnNames) <- letters[1:NROW(YourDataFrameWithRowAndColumnNames)] @@ -832,7 +829,7 @@ write.simple.tsv <- function( #' @param manualFileName Manually defined filename, overrides automatic naming. Default: NULL. #' @param manualDirectory Directory to save the file in, overrides default directory. Default: NULL. #' @param o If TRUE, opens the file after writing on OS X using 'system(open ...)'. Default: FALSE. -#' @param v verbose Print path? Default: TRUE. +#' @param v Print path if verbose? Default: TRUE. #' #' @return Appends data to an existing .tsv file. #' @examples @@ -882,11 +879,11 @@ write.simple.append <- function(input_df, filename = substitute(input_df), suffi #' The function offers various styling and formatting options for the Excel file. #' #' @param named_list A list of data frames or matrices to write out. -#' Default: No default value, a list must be provided. +#' Default: No default value; a list must be provided. #' @param rowname_column The column name or index to use as row names in the Excel file. -#' Required, no default value. +#' Default: 1. #' @param filename The base name for the output file, derived from the 'named_list' variable if not specified. -#' Default: Derived using 'substitute(named_list)'. +#' Default: Derived using `substitute(named_list)`. #' @param suffix A suffix to be added to the output filename. Default: NULL. #' @param manual_file_name Manually defined filename, overrides automatic naming. Default: NULL. #' @param manual_directory Directory to save the file in, overrides default directory. Default: NULL. @@ -898,10 +895,10 @@ write.simple.append <- function(input_df, filename = substitute(input_df), suffi #' @param HeaderLineColor Color for the header line. Default: 'darkolivegreen3'. #' @param HeaderCharStyle Character style for the header (e.g., 'bold', 'italic', 'underline'). #' Default: 'bold'. -#' @param has_row_names Logical; if set to FALSE, converts the first column to row names. Default: TRUE +#' @param has_row_names Logical; if set to FALSE, converts the first column to row names. Default: TRUE. #' @param FreezeFirstRow Logical; if TRUE, freezes the first row in Excel. Default: TRUE. #' @param FreezeFirstCol Logical; if TRUE, freezes the first column in Excel. Default: FALSE. -#' @param v verbose Print path? Default: TRUE. +#' @param v Print path if verbose? Default: TRUE. #' #' @examples #' \dontrun{ @@ -978,13 +975,12 @@ write.simple.xlsx <- function( #' @title Convert and save a .qs file to different formats #' -#' @description -#' This function reads in a `.qs` file and resaves it as either a `.tsv`, `.csv`, semicolon-separated +#' @description Reads in a `.qs` file and resaves it as either a `.tsv`, `.csv`, semicolon-separated #' `.csv` (csv2), or Excel file based on the `out_file` argument. #' -#' @param path A character string specifying the path to the `.qs` file. Default: none. +#' @param path A character string specifying the path to the `.qs` file. Default: None. #' @param out_file A character string specifying the output file format. One of `"tsv"` (default), -#' `"csv"`, `"csv2"` (semicolon-separated), or `"excel"`. Default: `"tsv"`. +#' `"csv"`, `"csv2"` (semicolon-separated), or `"excel"`. #' #' @return The function does not return a value but writes the file to disk in the specified format. #' From ebe649be4cb1be840748a91c7717fbb95eab8299 Mon Sep 17 00:00:00 2001 From: Abel Vertesy Date: Wed, 6 Aug 2025 12:27:35 +0200 Subject: [PATCH 2/6] Fix documentation typos and metadata (#17) --- DESCRIPTION | 2 +- Development/Development.bac | 6 +++--- Development/ReadWriter.orig.R | 2 +- R/Deprecated.Functions.R | 2 +- R/list.of.functions.in.ReadWriter.md | 6 +++--- README.md | 8 ++++---- man/column.2.row.names.Rd | 4 ++-- man/read.simple.csv.named.vector.Rd | 2 +- man/read.simple.ssv.Rd | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1cfdb5a..569852a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -16,6 +16,6 @@ Imports: qs, readr Encoding: UTF-8 -Packaged: 2025-07-14 12:49:22.339709 +Packaged: 2024-07-14 12:49:22.339709 Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.1 diff --git a/Development/Development.bac b/Development/Development.bac index 556d3ab..8b361af 100644 --- a/Development/Development.bac +++ b/Development/Development.bac @@ -14,7 +14,7 @@ #' @title Convert a Column to Row Names in a Tibble or DataFrame #' #' @description Converts the first column (or a specified column) of a dataframe or tibble into row names. -#' This function differs from `tibble::column_to_rownames` in that it takes column names or inices and +#' This function differs from `tibble::column_to_rownames` in that it takes column names or indices and #' it offers the option to sanitize row names using `make.names`, provides a warning if there are #' duplicated values in the row name column #' @@ -27,7 +27,7 @@ #' @param as_df Boolean indicating whether to convert the input to a dataframe if it's not already one. #' Default: TRUE. #' @param warn Warn user if row names pre-exist. -#' @param ... Pass arguments to make.names().. +#' @param ... Pass arguments to make.names(). #' @export column.2.row.names <- function( @@ -359,7 +359,7 @@ read.simple.csv <- function( # _________________________________________________________________________________________________ #' @title read.simple.ssv -#' @description Space separeted values. Read in a file with excel style data: +#' @description Space separated values. Read in a file with excel style data: #' rownames in col1, headers SHIFTED. The header should start with a #' TAB / First column name should be empty. #' @param ... Multiple simple variables to parse. diff --git a/Development/ReadWriter.orig.R b/Development/ReadWriter.orig.R index 55bdfde..bd43e80 100644 --- a/Development/ReadWriter.orig.R +++ b/Development/ReadWriter.orig.R @@ -78,7 +78,7 @@ read.simple.csv <- function(..., colnames = TRUE, coltypes = NULL, wRownames = return(read_in) } -read.simple.ssv <- function(..., sep_ = " ", colnames = TRUE, wRownames = TRUE, NaReplace = TRUE, coltypes = NULL) { # Space separeted values. Read in a file with excel style data: rownames in col1, headers SHIFTED. The header should start with a TAB / First column name should be empty. +read.simple.ssv <- function(..., sep_ = " ", colnames = TRUE, wRownames = TRUE, NaReplace = TRUE, coltypes = NULL) { # Space separated values. Read in a file with excel style data: rownames in col1, headers SHIFTED. The header should start with a TAB / First column name should be empty. pfn = kollapse(...) # merge path and filename read_in = suppressWarnings(readr::read_delim( pfn, delim = sep_, col_names = colnames, col_types = coltypes )) iprint("New variable dim: ", dim(read_in) - 0:1) diff --git a/R/Deprecated.Functions.R b/R/Deprecated.Functions.R index d7ca389..e14fbfa 100644 --- a/R/Deprecated.Functions.R +++ b/R/Deprecated.Functions.R @@ -26,7 +26,7 @@ read.simple.xls <- function(pfn = kollapse(...), row_namePos = NULL, ..., header .Deprecated("read.simple.xlsx") if (!require("gdata")) { - print("Please install gplots: install.packages('gdata')") + print("Please install gdata: install.packages('gdata')") } if (grepl("^~/", pfn)) { iprint("You cannot use the ~/ in the file path! It is replaced by '~/'.") diff --git a/R/list.of.functions.in.ReadWriter.md b/R/list.of.functions.in.ReadWriter.md index 7506f26..744b742 100644 --- a/R/list.of.functions.in.ReadWriter.md +++ b/R/list.of.functions.in.ReadWriter.md @@ -35,16 +35,16 @@ read.simple.csv. Read in a file with excel style data: rownames in col1, read.simple.csv.named.vector. Read in a file with excel style data: rownames in col1, - #### 12 `read.simple.ssv()` -read.simple.ssv. Read in a data frame (csv), and extact a value and a name column, and convert them +read.simple.ssv. Read in a data frame (csv), and extract a value and a name column, and convert them - #### 13 `read.simple.tsv.named.vector()` -read.simple.tsv.named.vector. Space separeted values. Read in a file with excel style data: +read.simple.tsv.named.vector. Space separated values. Read in a file with excel style data: - #### 14 `read.simple.xlsx()` Read a multi-sheet XLSX easily. Read in a file with excel style named vectors, names in col1, - #### 15 `write.simplest()` -Append or write a vector to standard file, one element per line.. Reads specified sheets from an XLSX file into a list of data frames. +Append or write a vector to standard file, one element per line. Reads specified sheets from an XLSX file into a list of data frames. - #### 16 `write.simple()` Write Simple. Alternative to clipboard. This function takes a vector and appends it diff --git a/README.md b/README.md index 8163a6c..726e465 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ source("https://raw.githubusercontent.com/vertesy/ReadWriter/main/R/ReadWriter.R Updated: 2024/10/24 13:48 - #### 1 `column.2.row.names()` -Convert a Column to Row Names in a Tibble or DataFrame. Converts the first column (or a specified column) of a dataframe or tibble into row names. This function differs from `tibble::column_to_rownames` in that it takes column names or inices and it offers the option to sanitize row names using `make.names`, provides a warning if there are duplicated values in the row name column +Convert a Column to Row Names in a Tibble or DataFrame. Converts the first column (or a specified column) of a dataframe or tibble into row names. This function differs from `tibble::column_to_rownames` in that it takes column names or indices and it offers the option to sanitize row names using `make.names`, provides a warning if there are duplicated values in the row name column - #### 2 `FirstCol2RowNames()` FirstCol2RowNames. Set First Col to Row Names @@ -77,10 +77,10 @@ read.simple.tsv. Read in a file with excel style data: rownames in col1, header read.simple.csv. Read in a file with excel style data: rownames in col1, headers SHIFTED. The header should start with a TAB / First column name should be empty. - #### 11 `read.simple.csv.named.vector()` -read.simple.csv.named.vector. Read in a data frame (csv), and extact a value and a name column, and convert them to a named vector. By default, it assumes the names in the first column and the values excel style named vectors, names in col1, headers SHIFTED. The header should start with a TAB / First column name should be empty. +read.simple.csv.named.vector. Read in a data frame (csv), and extract a value and a name column, and convert them to a named vector. By default, it assumes the names in the first column and the values excel style named vectors, names in col1, headers SHIFTED. The header should start with a TAB / First column name should be empty. - #### 12 `read.simple.ssv()` -read.simple.ssv. Space separeted values. Read in a file with excel style data: rownames in col1, headers SHIFTED. The header should start with a TAB / First column name should be empty. +read.simple.ssv. Space separated values. Read in a file with excel style data: rownames in col1, headers SHIFTED. The header should start with a TAB / First column name should be empty. - #### 13 `read.simple.tsv.named.vector()` read.simple.tsv.named.vector. Read in a file with excel style named vectors, names in col1, headers SHIFTED. The header should start with a TAB / First column name should be empty. @@ -89,7 +89,7 @@ read.simple.tsv.named.vector. Read in a file with excel style named vectors, nam Read a multi-sheet XLSX easily. Reads specified sheets from an XLSX file into a list of data frames. It allows customization of column names, row names, and trimming of white spaces. - #### 15 `write.simplest()` -Append or write a vector to standard file, one element per line.. Alternative to clipboard. This function takes a vector and appends it to a specified file. +Append or write a vector to standard file, one element per line. Alternative to clipboard. This function takes a vector and appends it to a specified file. - #### 16 `write.simple()` Write Simple. Writes a matrix-like R object (e.g., a data frame) to a file as tab-separated values (.tsv). The output filename can be auto-generated from the variable's name or manually specified. The file is saved in the specified output directory or the current working directory. The path and variable name can be passed separately and will be concatenated to form the filename. diff --git a/man/column.2.row.names.Rd b/man/column.2.row.names.Rd index 346b6d2..8d72c77 100644 --- a/man/column.2.row.names.Rd +++ b/man/column.2.row.names.Rd @@ -31,11 +31,11 @@ Default: TRUE.} \item{overwrite}{Overwrite row names if they already exist. Default: TRUE.} -\item{...}{Pass arguments to make.names()..} +\item{...}{Pass arguments to make.names().} } \description{ Converts the first column (or a specified column) of a dataframe or tibble into row names. -This function differs from \code{tibble::column_to_rownames} in that it takes column names or inices and +This function differs from \code{tibble::column_to_rownames} in that it takes column names or indices and it offers the option to sanitize row names using \code{make.names}, provides a warning if there are duplicated values in the row name column } diff --git a/man/read.simple.csv.named.vector.Rd b/man/read.simple.csv.named.vector.Rd index 34c63df..ad5f0f1 100644 --- a/man/read.simple.csv.named.vector.Rd +++ b/man/read.simple.csv.named.vector.Rd @@ -27,7 +27,7 @@ read.simple.csv.named.vector( \item{...}{Additional arguments passed to \code{\link[readr]{read_csv}} or read_csv2.} } \description{ -Read in a data frame (csv), and extact a value and a name column, and convert them +Read in a data frame (csv), and extract a value and a name column, and convert them to a named vector. By default, it assumes the names in the first column and the values excel style named vectors, names in col1, headers SHIFTED. The header should start with a TAB / First column name diff --git a/man/read.simple.ssv.Rd b/man/read.simple.ssv.Rd index 86fa0c2..0cfba7f 100644 --- a/man/read.simple.ssv.Rd +++ b/man/read.simple.ssv.Rd @@ -27,7 +27,7 @@ read.simple.ssv( \item{coltypes}{What type of variables are in columns? Auto-guessing can be very slow., Default: NULL} } \description{ -Space separeted values. Read in a file with excel style data: +Space separated values. Read in a file with excel style data: rownames in col1, headers SHIFTED. The header should start with a TAB / First column name should be empty. } From e970ea762f3b845d5afba82bb0bcd45c37773c01 Mon Sep 17 00:00:00 2001 From: Abel Vertesy Date: Wed, 6 Aug 2025 12:47:48 +0200 Subject: [PATCH 3/6] Add AGENTS guide for repository (#19) --- AGENTS.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 AGENTS.md diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..a94afd8 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,28 @@ +# AGENTS.md + +## Overview +ReadWriter is an R package providing convenience functions for reading from and writing to text-based data files. The package aims to streamline common I/O tasks and complements other tools in the `@vertesy` ecosystem. + +## Repository structure +- `R/` – source code. All exported functions live in `ReadWriter.R`; deprecated helpers are kept in `Deprecated.Functions.R`. +- `man/` – autogenerated documentation for functions (update with `devtools::document`). +- `Development/` – scripts used to build or maintain the package; not installed with the package. +- `DESCRIPTION` – package metadata and dependency declarations. +- `README.md` – installation instructions and a high-level overview. + +## Dependencies +- Requires the `@vertesy` package [`Stringendo` (>=0.5.0)](https://github.com/vertesy/Stringendo) and CRAN packages `gtools`, `openxlsx`, `qs`, and `readr`. +- Install `Stringendo` before installing ReadWriter: + ```r + devtools::install_github("vertesy/Stringendo", upgrade = FALSE) + ``` +- Add any new dependencies to the `Imports` field in `DESCRIPTION`. + +## Development guidelines +- Place new functions in `R/ReadWriter.R` and document them with roxygen comments. +- Run `R -q -e "devtools::document()"` to regenerate Rd files before committing. +- Verify the package with `R -q -e "devtools::check(document = FALSE)"`; checks should pass with no errors. +- There is currently no automated test suite. Manual testing of new functionality is encouraged. + +## Getting started +New contributors should read `README.md` for installation details and review `R/ReadWriter.R` to understand available functions. For broader context and utility helpers, explore the `Stringendo` package and other repositories in the `@vertesy` organization. From be3f9c12dd3522c71a19eb9bbdeccb67f462f712 Mon Sep 17 00:00:00 2001 From: Abel Vertesy Date: Wed, 6 Aug 2025 12:48:24 +0200 Subject: [PATCH 4/6] Add defensive stopifnot checks to file path builder (#18) --- R/ReadWriter.R | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/R/ReadWriter.R b/R/ReadWriter.R index eaa6826..1a6e2f7 100644 --- a/R/ReadWriter.R +++ b/R/ReadWriter.R @@ -41,14 +41,24 @@ column.2.row.names <- function(tibble, rowname_column = 1, # Assertions stopifnot( is.data.frame(tibble), - # is.numeric(rowname_column), - rowname_column > 0, - rowname_column <= ncol(tibble), - is.logical(make_names), is.logical(as_df) + is.logical(make_names), is.logical(as_df), + is.logical(warn), is.logical(overwrite) ) + if (is.numeric(rowname_column)) { + stopifnot(rowname_column >= 1, rowname_column <= ncol(tibble)) + col_idx <- rowname_column + } else if (is.character(rowname_column)) { + stopifnot(rowname_column %in% colnames(tibble)) + col_idx <- match(rowname_column, colnames(tibble)) + } else { + stop("`rowname_column` must be a numeric index or column name.") + } + if (!is.null(rownames(tibble))) { if (warn) { + old_warn <- getOption("warn") + on.exit(options(warn = old_warn), add = TRUE) options(warn = -1) # this should not be necessary warning("tibble/df already has row names:", immediate. = TRUE) print(head(rownames(tibble))) @@ -61,13 +71,14 @@ column.2.row.names <- function(tibble, rowname_column = 1, } # Extracting the specified column to be used as row names - row_names <- tibble[[rowname_column]] + row_names <- tibble[[col_idx]] # Check for duplicated row names - if (anyDuplicated(rowname_column)) { - is.duplicated <- rowname_column[which(duplicated(rowname_column))] + dup_idx <- which(duplicated(row_names)) + if (length(dup_idx) > 0) { + dup_vals <- row_names[dup_idx] warning( - length(is.duplicated), " duplicated entries in: ", substitute(rowname_column), + length(dup_vals), " duplicated entries in ", colnames(tibble)[col_idx], "\narg make_names = TRUE will enforce uniqueness" ) } @@ -78,7 +89,7 @@ column.2.row.names <- function(tibble, rowname_column = 1, } # Removing the rowname column from the dataframe - tibble <- tibble[, -rowname_column, drop = FALSE] + tibble <- tibble[, -col_idx, drop = FALSE] # Setting the row names if (overwrite) { @@ -149,6 +160,7 @@ FirstCol2RowNames.as.df <- function(Tibble, rownamecol = 1, make_names = FALSE) #' #' @description Constructs a complete file path using either provided manual file name and directory #' or defaults to processing a given filename and using the current working directory. +#' At least one of `filename` or `manual_file_name` must be supplied. #' #' @param filename The base file name to process. Default: NULL. #' @param suffix The file name suffix to be appended. Default: NULL. @@ -171,24 +183,27 @@ construct.file.path <- function( manual_file_name = NULL, manual_directory = NULL, v = TRUE) { - filename <- as.character(filename) # unclear why thus bf needed. + if (!is.null(filename)) filename <- as.character(filename) # unclear why thus bf needed. # Input argument assertions stopifnot( is.null(filename) || is.character(filename), + is.null(suffix) || is.character(suffix), + is.null(extension) || is.character(extension), is.null(manual_file_name) || is.character(manual_file_name), is.null(manual_directory) || is.character(manual_directory), - is.null(extension) || is.character(extension) + !is.null(filename) || !is.null(manual_file_name) ) fname <- if (!is.null(manual_file_name)) manual_file_name else Stringendo::sppp(filename, suffix) out_dir <- if (!is.null(manual_directory)) manual_directory else getwd() + stopifnot(dir.exists(out_dir)) # Construct the full file path FnP <- Stringendo::ParseFullFilePath(out_dir, fname, extension) # Output assertion - stopifnot(is.character(FnP), nzchar(FnP)) + stopifnot(is.character(FnP), length(FnP) == 1, nzchar(FnP)) if (v) { try(message(osXpath(FnP))) From 8431b789c24266346a195f5638d8270a3ed5eedb Mon Sep 17 00:00:00 2001 From: Abel Vertesy Date: Mon, 31 Aug 2026 22:38:36 +0200 Subject: [PATCH 5/6] Annotate code: explain the non-obvious operations (#30) * Annotate code; flag 3 pre-existing bugs (not fixed) * Fix 3 bugs flagged in PR #30 review - read.simple.ssv(): add missing `asTibble` parameter (was referenced but never defined, erroring whenever wRownames = TRUE, the default). - write.simple.xlsx(): assignRownames() now uses its own argument `x` instead of the undefined `df`, fixing has_row_names = FALSE. - qs.2.table(): fix `qs:qread` -> `qs::qread`, use the real `stringi::stri_detect_regex` function, and define `base_filename`/ `out_path` on every branch so the function actually runs. Also adds `stringi` to Imports/NAMESPACE since it's now genuinely used. Co-authored-by: Abel Vertesy <5101911+vertesy@users.noreply.github.com> * Fix qs.2.table()'s excel branch crashing on a bare data.frame write.simple.xlsx() requires a list of sheets; qs.2.table() was passing the loaded table directly, which fails its is.data.frame(x)-per-element assertion. Wrap it in a list first. Co-Authored-By: Claude Sonnet 5 --------- Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Abel Vertesy <5101911+vertesy@users.noreply.github.com> Co-authored-by: Claude Sonnet 5 --- DESCRIPTION | 5 +++-- NAMESPACE | 1 + R/ReadWriter.R | 57 +++++++++++++++++++++++++------------------------- 3 files changed, 33 insertions(+), 30 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 569852a..6b3860c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -10,11 +10,12 @@ License: GPL-3 + file LICENSE BugReports: https://github.com/vertesy/ReadWriter/issues Depends: Stringendo (>= 0.5.0) -Imports: +Imports: gtools, openxlsx, qs, - readr + readr, + stringi Encoding: UTF-8 Packaged: 2024-07-14 12:49:22.339709 Roxygen: list(markdown = TRUE) diff --git a/NAMESPACE b/NAMESPACE index ec03e82..9310f79 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -33,3 +33,4 @@ importFrom(readr,read_csv) importFrom(readr,read_csv2) importFrom(readr,read_delim) importFrom(readr,read_tsv) +importFrom(stringi,stri_detect_regex) diff --git a/R/ReadWriter.R b/R/ReadWriter.R index 1a6e2f7..3ee1978 100644 --- a/R/ReadWriter.R +++ b/R/ReadWriter.R @@ -36,7 +36,7 @@ column.2.row.names <- function(tibble, rowname_column = 1, warn = TRUE, overwrite = TRUE, ...) { - "This is the function that should be used from 11.2023" + # This is the function that should be used from 11.2023 # Assertions stopifnot( @@ -94,6 +94,8 @@ column.2.row.names <- function(tibble, rowname_column = 1, # Setting the row names if (overwrite) { message("Overwriting row names.") + # Clear existing row names first, so setting the new ones can't collide + # with the old set (data.frame rownames<- errors on duplicates otherwise). rownames(tibble) <- NULL rownames(tibble) <- row_names } else { @@ -452,6 +454,7 @@ read.simple.csv.named.vector <- function(file, sep = ";", col_names = FALSE, #' @param wRownames With row names? Default: TRUE. #' @param NaReplace Replace NA values? Default: TRUE. #' @param coltypes What type of variables are in columns? Auto-guessing can be very slow. Default: NULL. +#' @param asTibble Load as tibble or data frame? Default: FALSE (load as data frame). #' @examples #' \dontrun{ #' if (interactive()) { @@ -465,17 +468,16 @@ read.simple.csv.named.vector <- function(file, sep = ";", col_names = FALSE, #' @importFrom readr read_delim #' @importFrom gtools na.replace read.simple.ssv <- function( - ..., sep_ = " ", colnames = TRUE, wRownames = TRUE, NaReplace = TRUE, - coltypes = NULL) { + ..., sep_ = " ", colnames = TRUE, wRownames = TRUE, NaReplace = TRUE, + coltypes = NULL, asTibble = FALSE +) { pfn <- Stringendo::kollapse(...) # merge path and filename read_in <- suppressWarnings(readr::read_delim(pfn, delim = sep_, col_names = colnames, col_types = coltypes)) - iprint("New variable dim: ", dim(read_in) - 0:1) - if (wRownames) { - read_in <- FirstCol2RowNames(read_in) - } - if (NaReplace) { - read_in <- as.data.frame(gtools::na.replace(read_in, replace = 0)) - } + Stringendo::iprint("New variable dim: ", dim(read_in) - 0:1) + + if (wRownames) read_in <- column.2.row.names(read_in, as_df = !asTibble) + if (NaReplace) read_in <- as.data.frame(gtools::na.replace(read_in, replace = 0)) + return(read_in) } @@ -792,7 +794,7 @@ write.simple.tsv <- function( col_names <- TRUE } - " write.simple.tsv should have background compression as a feature #14 " + # TODO: write.simple.tsv should have background compression as a feature #14 if (separator %in% c(",", ";")) extension <- "csv" @@ -956,8 +958,8 @@ write.simple.xlsx <- function( ) # assign row names if required - if (!has_row_names) { - assignRownames <- function(x) column.2.row.names(df, rowname_column = rowname_column, make_names = TRUE) + if (isFALSE(has_row_names)) { + assignRownames <- function(x) column.2.row.names(x, rowname_column = rowname_column, make_names = TRUE) named_list <- lapply(named_list, assignRownames) message("Converting column ", rowname_column, " to row names: ", head(rownames(named_list[[1]]))) } @@ -1000,38 +1002,37 @@ write.simple.xlsx <- function( #' @return The function does not return a value but writes the file to disk in the specified format. #' #' @importFrom qs qread -#' @export +#' @importFrom stringi stri_detect_regex #' +#' @export qs.2.table qs.2.table <- function(path, out_file = c("tsv", "csv", "csv2", "excel")[1]) { # Ensure that the file exists and is a .qs file - stopifnot(file.exists(path), stringi::stri_detect(str = path, regex = "\\.qs$")) + stopifnot(file.exists(path), stringi::stri_detect_regex(str = path, pattern = "\\.qs$")) # Ensure out_file is one of the allowed choices out_file <- match.arg(out_file, c("tsv", "csv", "csv2", "excel")) # Read in the .qs file - data <- qs:qread(path) + data <- qs::qread(path) - # Determine the output file extension and write the file based on the output format - path_out <- ppp(base_filename, out_file) - - if (out_file == "excel") { - # out_path <- ppp(base_filename, "xlsx") - ppp(base_filename, out_file) - ReadWriter::write.simple.xlsx(data, out_path) - } + # Base name (without extension) shared by all output formats + base_filename <- sub("\\.qs$", "", path) if (out_file == "tsv") { - ReadWriter::write.simple.tsv(data, path_out, separator = "\t") + ReadWriter::write.simple.tsv(data, manual_file_name = base_filename, separator = "\t") + out_path <- paste0(base_filename, ".tsv") } else if (out_file == "csv") { - ReadWriter::write.simple.tsv(data, path_out, separator = ",") + ReadWriter::write.simple.tsv(data, manual_file_name = base_filename, separator = ",") + out_path <- paste0(base_filename, ".csv") } else if (out_file == "csv2") { + ReadWriter::write.simple.tsv(data, manual_file_name = base_filename, separator = ";") out_path <- paste0(base_filename, ".csv") - ReadWriter::write.simple.tsv(data, path_out, separator = ";") } else if (out_file == "excel") { + # write.simple.xlsx() expects a list of sheets; wrap a bare table into one. + payload <- if (is.data.frame(data) || is.matrix(data)) list(data) else data + ReadWriter::write.simple.xlsx(payload, manual_file_name = base_filename) out_path <- paste0(base_filename, ".xlsx") - ReadWriter::write.simple.xlsx(data, out_path) } message("File saved as: ", out_path) From b74b0d5c7cfae4ec333ce4e1d9cf4d270c84e0cd Mon Sep 17 00:00:00 2001 From: "claude[bot]" <41898282+claude[bot]@users.noreply.github.com> Date: Tue, 1 Sep 2026 06:58:24 +0000 Subject: [PATCH 6/6] Address Codex review: declare stringi dependency, preserve row names on xlsx export - DESCRIPTION: add stringi to Imports, since R/ReadWriter.R now calls stringi::stri_detect_regex() and NAMESPACE already declares the importFrom. - write.simple.xlsx(): when has_row_names = FALSE, the identifier column is moved into row names via column.2.row.names() before writing. The final write.xlsx() call still passed the original has_row_names (FALSE) as rowNames, so those converted identifiers were dropped from the workbook. Track the post-conversion state separately (write_row_names) and pass that to write.xlsx() instead. Co-authored-by: Abel Vertesy <5101911+vertesy@users.noreply.github.com> --- DESCRIPTION | 5 +++-- R/ReadWriter.R | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1b1aebc..f4f3d37 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -9,11 +9,12 @@ License: GPL-3 + file LICENSE BugReports: https://github.com/vertesy/ReadWriter/issues Depends: Stringendo (>= 0.5.0) -Imports: +Imports: gtools, openxlsx, qs, - readr + readr, + stringi Encoding: UTF-8 Packaged: 2026-08-25 16:41:37.734198 Roxygen: list(markdown = TRUE) diff --git a/R/ReadWriter.R b/R/ReadWriter.R index 18ed355..c197c54 100644 --- a/R/ReadWriter.R +++ b/R/ReadWriter.R @@ -957,10 +957,12 @@ write.simple.xlsx <- function( ) # assign row names if required + write_row_names <- has_row_names if (isFALSE(has_row_names)) { assignRownames <- function(x) column.2.row.names(x, rowname_column = rowname_column, make_names = TRUE) named_list <- lapply(named_list, assignRownames) message("Converting column ", rowname_column, " to row names: ", head(rownames(named_list[[1]]))) + write_row_names <- TRUE # the converted identifiers must still be written as the sheet's row names } FnP <- construct.file.path( @@ -970,7 +972,7 @@ write.simple.xlsx <- function( ) openxlsx::write.xlsx( - x = named_list, file = FnP, rowNames = has_row_names, + x = named_list, file = FnP, rowNames = write_row_names, firstRow = FreezeFirstRow, firstCol = FreezeFirstCol, headerStyle = hs, tabColour = TabColor, colWidths = "auto", creator = Creator