我創建了一個腳本,用戶最初被要求輸入一些分配給變量的輸入。但是,當您啓動腳本時,R不會等待用戶輸入輸入來執行操作。在腳本啓動之前,我如何告訴R等待用戶的輸入?實際上,我的代碼如下所示:只需要R在開始執行動作之前等待用戶輸入
fun <- function(){
x <<- readline("What is the value of x?")
y <<- readline("What is the value of y?")
z <<- readline("What is the value of z?")
}
fun()
#BEGIN OF THE SCRIPT USING X, Y, Z
這段代碼在這裏工作。注意你不知道double ** << **;使用* <*代替R文檔中顯示的https://stat.ethz.ch/R-manual/R-devel/library/base/html/readline.html – tagoma