I have a warning message I want to display only once during a session. Is there a fancy way to do this that doesn't involve storing a new object in the environment and checking it's value each time?
value <- 2
checkval <- function(x) if(x == 2) message("Warning, value is 2. This message will only be displayed once")
checkval(value)
#> Warning, value is 2. This message will only be displayed once
checkval(value) #second time, don't want it to display the warning.
#> Warning, value is 2. This message will only be displayed once
Created on 2020-03-12 by the reprex package (v0.3.0)