When mapply is applied to a function that has a call to browser() within it, the result can be a disastrous amount of feedback.
To clarify this situation please consider the following function, containing a call to browser within it: plus = function(a, b) {browser(); a + b} A plain vanilla call to plus() yields the following: LAPTOP_32G_01> plus(1,2) Called from: plus(1, 2) Browse[1]> [1] 3 Now consider the following application of mapply to plus: LAPTOP_32G_01> mapply(plus, 1:2, 1:2) Called from: (function (a, b) { browser() a + b })(dots[[1L]][[1L]], dots[[2L]][[1L]]) Browse[1]> Called from: (function (a, b) { browser() a + b })(dots[[1L]][[2L]], dots[[2L]][[2L]]) Browse[1]> [1] 2 4 Notice that at each step, after the browser is called, mapply prints out the function call including its arguments: Called from: (function (a, b) { browser() a + b })(dots[[1L]][[1L]], dots[[2L]][[1L]]) etc. In the present case this does no harm except to make things a little harder to read. However, if one of the inputs happens to be a data frame with a million rows, the entire million rows are printed to the screen. I have been bitten by this, which is why I am writing this note. I have a question and a request: Question: Is there some way to prevent mapply (or browser) from echoing the function call when browser is called from within FUN? Request: If not, could the ability to turn off this echoing be provided. As things stand, calling browser from within FUN, when FUN is a realistically big function or has realistically big arguments, is a disaster. Thanks. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.