Using Sys.sleep in R function to delay multiple outputs

后端 未结 2 517
野趣味
野趣味 2021-01-26 14:13

I have this function:

func<-function(name){
    paste(\"Your name is. . .\")
    Sys.sleep(1.5)
    paste(name)
}

This function obviously wo

2条回答
  •  孤街浪徒
    2021-01-26 15:04

    I'm not quite sure what the question is, but this produces the behavior you are talking about.

    func <- function(name)
    {
    print("Your name is. . .")
    flush.console()
    Sys.sleep(1.5)
    print(name)
    }
    
    > func('Test')
    [1] "Your name is. . ."
    [1] "Test"
    > 
    

提交回复
热议问题