1
我有一個想法,暫停在一些迭代循環,並要求「用戶」的一些答案。R語言,暫停循環,並要求用戶繼續
例如
some_value = 0
some_criteria = 50
for(i in 1:100)
{
some_value = some_value + i
if(some_value > some_criteria)
{
#Here i need to inform the user that some_value reached some_criteria
#I also need to ask the user whether s/he wants to continue operations until the loop ends
#or even set new criteria
}
}
同樣,我想暫停循環,並詢問用戶是否願意繼續這樣的:「按Y/N」
相關[如何等R按鍵?](http://stackoverflow.com/questions/15272916/how-to-wait-for-a-keypress-in-r)和[用戶輸入R(Rscript和Widows命令提示符)](http://stackoverflow.com/questions/22895370/user-input-in-r-rscript-and-widows-command-prompt)。 – lmo