I'm making changes to a package and I'd like to inform the user when he loads it for the first time, but not afterwards. I can use interactive()
to check if R is being run interactively, but is there a simple way to record that the message has already been shown on this computer? Are there any functions which handle this?
you could write an .onload() function to give the message and then edit an .Rprofile or .Renviron file so that the message wouldn't be given again
rlang::warn()
and rlang::abort()
have a .frequency
argument, but the least frequent they go to is once per session. "What has changed" is an interesting use case, though. I'll be interested to hear what people think!
I think I'd use {rappdirs} to store something in a package dir telling you that they've already seen it. I'd probably prompt the user to make sure it's ok to store that (and telling them that the message won't appear again).
Let us know how it goes!
I understand the motivation, but that would make this message very annoying. If the user opts out, then you cannot store the fact that they have opted out, so the question would appear again when you load the package the next time.
So it is better not to ask, but just show the message, and then write the version number into a file in the cache directory., using rappdirs or tools::R_user_dir()
. (The latter needs R 4.0.)
Oh good call! I hadn't thought that through far enough!
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.