I am trying to create a function in R, consisiting of 4 parts, which would run this parts separately. So after calling a function the first part gets executed and give me an output. The function does not close. Than I press Enter, the second part is run ang shows an output. Than after pressing Enter I get the third part executed and after the last press I have the forth part output and only than the function closes. Can anybody help me?
Asked
Active
Viewed 108 times
0
-
3Try `?readline` in the console. Also, perhaps review the [minimal reproducible example guidelines](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – hrbrmstr Mar 23 '14 at 14:44
1 Answers
0
An arbitrary function that demonstrates the use of hrbrmstr's suggestion of readline
is below:
a_b <- function(a, b){
a_b_plus <- paste('the answer of a + b is:', a + b)
print(a_b_plus)
line <- readline()
a_b_minus <- paste('the answer of a - b is:', a - b)
print(a_b_minus)
line <- readline()
a_b_divide <- paste('the answer of a / b is:', a / b)
print(a_b_divide)
line <- readline()
}

maloneypatr
- 3,562
- 4
- 23
- 33