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

Add element of randomness in words chosen for incdec() #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

stanley-rudkin-moj
Copy link
Contributor

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 with incdec() 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 existing
seed 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". But incdec(-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.

@stanley-rudkin-moj
Copy link
Contributor Author

Could even make similar changes to change_desc() so it doesn't always return "increased/decreased"?

@stanley-rudkin-moj
Copy link
Contributor Author

And also change_desc() could potentially return the value itself as well as the phrase, e.g. "saw an increase of 3%"

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.

1 participant