user2641103
user2641103

Reputation: 702

Debugging in RStudio

If I use browser() function in a source file that is not in the current folder then RStudio complains that cannot find the file.

How can I instruct the debugger to find the source file where the breakpoint occurs?

Upvotes: 0

Views: 101

Answers (1)

Christoph
Christoph

Reputation: 7063

Place the function in Desktop/testfun.R:

fun <- function(a,b) {
  a <- 1
  b <- 2
  return(5)
}

Then the follwing works (You have to step into fun()):

{
  source("Desktop/testfun.R")
  browser()
  b <- fun(1,2)
}

If it is about debugging a package, have a look here

Upvotes: 1

Related Questions