ropensci / readODS

Read ODS (OpenDocument Spreadsheet) into R as data frame. Also support writing data frame into ODS file.
https://docs.ropensci.org/readODS/
Other
55 stars 22 forks source link

Clean up `sheet` #162

Closed chainsawriot closed 1 year ago

chainsawriot commented 1 year ago

The variable sheet has different meanings in the codebase.

Other than as the argument of read_ods and write_ods

it is an integer after standisation aka sheet_index in some places

https://github.com/ropensci/readODS/blob/f8fc6570957c3587254dff340e760d4b939d9c79/R/read_ods.R#L195-L196

here, the sheet in the name convert_df_to_sheet means a "sheet file"

https://github.com/ropensci/readODS/blob/f8fc6570957c3587254dff340e760d4b939d9c79/R/write_ods.R#L42-L47

In the C++ code, there is type but can still be confusing:

https://github.com/ropensci/readODS/blob/f8fc6570957c3587254dff340e760d4b939d9c79/src/write_sheet_.cpp#L128

https://github.com/ropensci/readODS/blob/f8fc6570957c3587254dff340e760d4b939d9c79/src/read_ods_.cpp#L10

May I propose this:

  1. sheet - use only in R to denote an argument that can either be a name or index
  2. sheet_index - use in R and C++ to denote an integer representing the sheet index, e.g. 2
  3. sheet_name - use in R and C++ to denote a string representing the sheet name, e.g. "Sheet1"
  4. sheet_file - use in R and C++ to denote the often throwaway XML file

Please keep using whatever works. I will clean this up after feature freeze for the next CRAN release.