Getting the state of variables after an error occurs in R

后端 未结 3 773
谎友^
谎友^ 2020-12-02 21:21

Let\'s say I have just called a function, f, and an error occurred somewhere in the function. I just want to be able to check out the values of different varia

3条回答
  •  情书的邮戳
    2020-12-02 22:07

    You could also just use the debug() function:

    > debug(f)
    > f(x,y)
    debugging in: f(x, y)
    debug: {
        y <- c(y, 1)
        lm(y ~ x)
    }
    Browse[1]> 
    debug: y <- c(y, 1)
    Browse[1]> x
    [1] 1 2 3 4 5
    Browse[1]> y
    [1] 2.146553 2.610003 2.869081 2.758753 4.433881
    

提交回复
热议问题