Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当用户中止 R 时,是否可以从当前迭代中返回数据?
就像是:
if (user.aborts == TRUE) { return(data) }
这将非常有用,因为此过程的输入只是数据。然后可以将其分解,然后继续。
如果您的意思是手动停止该过程,例如
myfun <- function(x){ on.exit(return(x)) for(i in 1:5){ x <- x + 1 Sys.sleep(1) } } x <- myfun(1) # Stopping before it finishes x [1] 4