break/exit script

前端 未结 8 1243
Happy的楠姐
Happy的楠姐 2021-01-30 15:22

I have a program that does some data analysis and is a few hundred lines long.

Very early on in the program, I want to do some quality control and if there is not enou

8条回答
  •  再見小時候
    2021-01-30 16:14

    Not pretty, but here is a way to implement an exit() command in R which works for me.

    exit <- function() {
      .Internal(.invokeRestart(list(NULL, NULL), NULL))
    }
    
    print("this is the last message")
    exit()
    print("you should not see this")
    

    Only lightly tested, but when I run this, I see this is the last message and then the script aborts without any error message.

提交回复
热议问题