Один из способов - создать временный файл, который может предоставить информацию о том, был ли checkval
вызван в текущем сеансе
checkval = function(value) {
checkTemp = list.files("~", "temp.txt")
currentTime = Sys.time()
start = currentTime - proc.time()["elapsed"]
attr(start, "tzone") = "UTC"
attr(currentTime, "tzone") = "UTC"
if (value == 2) {
if (length(checkTemp) == 0){
message("Message1")
cat(as.character(currentTime), file = "~/temp.txt", append = FALSE)
} else {
lastDate = as.POSIXct(readLines("~/temp.txt", warn = FALSE), tz = "UTC")
if (start > lastDate) {
message("Message2")
cat(as.character(currentTime), file = "~/temp.txt", append = FALSE)
}
}
}
}