我正在努力提出一个问题&答案格式,答案成为每个变量的输入。即,sex
和interest rate
此处。
cat("Select Sex", ":M = Male, F = Female", "\n", sep=" ")
Sex <- readline("Sex = ")
cat("Input interest rate in annual compounding basis", "\n", sep=" ")
interest.rate <- as.numeric(readline("Interest rate = "))
我需要在每个下面添加什么才能将每个答案作为输入?
我真的很感激!
答案 0 :(得分:0)
我不确定我是否理解这个问题,但如果我做得好,你会希望将来自read.line
的输入重新用作其他地方的输入吗?
那样的东西?
cat("Select Sex", ":M = Male, F = Female", "\n", sep=" ")
Sex <- readline("Sex = ")
cat("Input interest rate in annual compounding basis", "\n", sep=" ")
interest.rate <- as.numeric(readline("Interest rate = "))
cat(paste0("Input values where ", Sex, " (Sex) and ", interest.rate, " (interest rate)."))