Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

lapply() with user input

Tags:

r

Is there a way to use lapply() in a manner that forces it to wait for "enter" from the user before stepping through the next element of the list? If so, could you provide a simple example?

like image 936
Brandon Bertelsen Avatar asked Feb 20 '23 03:02

Brandon Bertelsen


1 Answers

Here is the example:

es <- list(1, 2, 3)
lapply(es, function(e) {
  cat("Press enter:")
  readLines(n = 1)
  print(e)
})
like image 148
kohske Avatar answered Mar 02 '23 23:03

kohske