Add element of randomness in words chosen for incdec() #30
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.
Can't take credit for this suggestion, because someone who left our team implemented it in our own RAP. But basically the idea is to get
incdec()
to randomly choose from a set of phrases each time it is called, so that any text written withincdec()
doesn't sound too repetitive.To ensure reproducibility, I added a new argument,
seed
, which is a random seed used within the function only. Any existingseed in your R environment will be restored after the function is called. Its default is NULL, which returns different results each time the function is called. But it can be set to a single number to guarantee it returns the same results every time.
For example,
incdec(-1, "past", seed = 14)
always returns "has fallen by". Butincdec(-1, "past")
can return any one of "has fallen by", "is down by", or "decreased by".I'm open to changing the default for
seed
to a single number which means the original phrases ( e.g. "increased by") are always used, thereby not affecting any team's existing code. But felt that this change at least shouldn't break any code if not.