suppose I have this function
function_to_run <- function(data){
a = 2 data
b = 4 9
c = 0
a = a b c
return(a)
}
what I want to do is execute each line in the function one at a time and be able to change the values, for example say I execute the second line b=4 9 but while in the function I want to change that in real time to b=5 9 instead, is there a way to do this.
If I use debug it will just allow me to execute but I can't run it. thanks
CodePudding user response:
You can run statements within debug: f() would have given 18 but it gave 19 because we run the highlighted statement.
> f <- function_to_run <- function() {
a = 2 3
b = 4 9
c = 0
a = a b c
return(a)
}
> debug(f)
> f()
debugging in: f()
debug at #1: {
a = 2 3
b = 4 9
c = 0
a = a b c
return(a)
}
Browse[2]>
debug at #2: a = 2 3
Browse[2]>
debug at #3: b = 4 9
Browse[2]>
debug at #4: c = 0
Browse[2]> b <- 5 9 # <-------------------- change b
Browse[2]>
debug at #5: a = a b c
Browse[2]>
debug at #6: return(a)
Browse[2]>
exiting from: f()
[1] 19
