-
Notifications
You must be signed in to change notification settings - Fork 11
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 random strings #281
Conversation
The onus is, we pollute the .GlobalEnv with our seed and if we want to set the seed for |
I use this in #280 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
withr::with_seed()
also checks seed type, which we may want to do as well: https://github.com/r-lib/withr/blob/main/R/seed.R
a7b4381
to
68ebefa
Compare
68ebefa
to
e9e0005
Compare
fixed the tests |
We could add a seed counter option. We set and increase in random_string() and use set.seed() with it. That would be the slimmest approach, but personally I'm fine with both. The current in this PR and the sketched idea as well. I see if I have time to add this later today, otherwise I'll merge with a to-do note. It's a minor function without much use at the moment. Unless someone wants to add styles or sparklines it isn't triggered at all. |
Scratch that last comment. Check complains therefore I'll change it.
|
This is a bit tricky and I'd be open to suggestions how to improve this or if we are fine with this. I needed it, to run a test and it works well. Therefore ... another suggestion must be better :)
This approach does not alter the seed when calling
random_string()
, even with strings of random sizes. I applied these in a row, but ran into a problem, where I actually wanted the seed to be altered when calling it inopenxlsx2
, therefore I've added a way foropenxlsx2
to handle such cases.Once
random_string()
is called:.openxlsx2.seed
, this is the seed we want to use.stringi
to create a random string for us..openxlsx2.seed
therefore once we callrandom_string()
again, it will pick up this seed.