I have a function something like this:
annotation <- function(){
start.time <- Sys.time()
cat("Please add a note to be concatenated to the output folder's name. Press \"Enter\" if you don't need.")
note <- readline()
if (note == ""){
return(note)
}
else{
note <- paste0("_", note)
}
end.time <- Sys.time()
if (end.time - start.time <= 5) {
return(note)
}else{
note <- ""
return(note)
}
}
However, this is not what I excepted, because what I want is: if there is no action within 5 second, the returned note will be ""
, otherwise, the returned note is what you input.
I know it lacks certain function to count down, but my R's ability is the bottleneck.
Also, if would be nice to show the time count down in the terminal once you execute the function.