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.
かなり時間がかかる可能性のある機能があります。
私はこのようなもの以外の機能を停止するためのよりクリーンな方法があるかどうか疑問に思いました:
repeat{ time1 <- Sys.time() myfunction(x,y,z,...) time2 <- Sys.time() if(time2 - time1 > my.time.limit) { break } }
R.utilsパッケージevalWithTimeoutに関数があります。次のように使用できます。
evalWithTimeout
require("R.utils") evalWithTimeout({ repeat{ myfunction(x,y,z,...) } }, timeout=my.time.limit, onTimeout="warning")
実行example(evalWithTimeout)して、他の使用方法を確認してください。
example(evalWithTimeout)