User input of time from the first keystroke in R

Looking at how much time a user needs to enter a message in R from the first keystroke.

I can use functions like readline()or scan()to get user input, and I can use system.time()to determine how long it takes to run the code:

> system.time(readline())
Test Message
   user  system elapsed 
   0.98    0.53   19.55

However, this gives me a common past tense. If I wait, wait 15 seconds before entering the text, this will be reflected in the output system.time(), and not just the time I took to write the message. (For example, 19.55s = 15s + ~ 4.5s I used to enter the message.)

You are looking for this in the console, but you are also ready to use a separate window if necessary.

+4
source share

Source: https://habr.com/ru/post/1689906/


All Articles