Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a starting point for input error-checking that gets us closer to closing #28 (which suggests more error-checks than class alone).
This PR adds an error-helper function that checks the class of inputs and provides tests (including snapshot tests for the rich error messages). Note that this adds dependencies on {rlang} and {cli}.
For now we only need to check numeric inputs, but I've added an
expected_class
argument that can check for character inputs as well. We can expand this later if we also need to check for data.frames, lists, etc.This PR replaces #45 (closed draft), which had a less-good version of the class-checking function. It also had a function to check that the length of inputs match, but recycling is default R behaviour and it might surprise users if we raise an error (though we might be able to intercept the warning that's thrown with something a bit more friendly). We should discuss this further.
I've removed the skeleton tests written by Chris, which will calm the linter down. These skeletons are in version history, so we can always go back and copy them if required in future.