Skip to content
Prev 419 / 12125 Next

[R-pkg-devel] Browser Level for Conditional Function Parameter

Good day,

Why do I get a debug message and a change in browser level when I inspect the title variable ? For the comparison variable, it simply prints its value and remains at level 1.

aFunction <- function(comparison = c("within", "classifier", "selection"),
                      title = if(comparison[1] == "within") "Internal" else "Between")
{
    browser()
    require(ggplot2)
    comparison <- match.arg(comparison)
    ggplot(mtcars, aes(wt, mpg)) + geom_point() + ggtitle(title)
}

aFunction()

Browse[1]> title
debug at #4: [1] "Internal"
Browse[3]>

--------------------------------------
Dario Strbenac
PhD Student
University of Sydney
Camperdown NSW 2050
Australia