Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve file examples #71

Merged
merged 4 commits into from
Sep 20, 2023
Merged

Improve file examples #71

merged 4 commits into from
Sep 20, 2023

Conversation

eloch216
Copy link
Owner

Some users had reported issues when reading files using read_gasex_file. After looking in to these issues, it was found that these users were directly copying the example code like

file_paths <- c(
  system.file('extdata', 'ball_berry_1.xlsx', package = 'PhotoGEA'),
  system.file('extdata', 'ball_berry_2.xlsx', package = 'PhotoGEA')
)

and replacing ball_berry_1.xslx and ball_berry_2.xlsx with their own file names.

This had a very confusing and unexpected result. First, system.file returned an empty string because it could not find the specified file. Then, read_gasex_file interpreted the empty string as if it were a plaintext Licor Li-6800 log file name. Eventually it encountered a problem when calling read.delim, and reported an unhelpful error message like Error in if (skip > 0L) readLines(file, skip) : argument is of length zero.

This PR addresses this problem in several ways:

  • read_gasex_file now returns a helpful error message if the file_name input is an empty string.
  • The examples involving system.file now all specify mustExist = TRUE. With this option, an error is generated if the file cannot be found, instead of the default behavior of returning an empty string.
  • The vignettes now clarify that system.file should not be used for loading the user's own files.

Hopefully now users will no longer copy the system.file command. If they do, they will probably also copy the mustExist = TRUE option, which will cause a more direct error message explaining that the file cannot be found. If a user somehow persists in passing an empty string to read_gasex_file, it will also produce a more informative error message.

@eloch216 eloch216 merged commit e2c651d into unreleased Sep 20, 2023
@eloch216 eloch216 deleted the improve-file-examples branch September 21, 2023 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant