[R] traceback and passing data frame

From: Daniel E. Ho <daniel.ho_at_yale.edu>
Date: Thu 07 Jul 2005 - 12:31:12 EST


Hello,

Is there a way to suppress traceback() from returning the full structure of a dataframe that is passed internally in a function?

As a simple toy example, suppose we had two functions that pass a dataframe internally:

data(Formaldehyde)
fn2 <- function(formula, data, ...) {
  res <- lm(formula, data, subset="some error", ...)
}

fn1 <- function(formula,data,...){
  tmp <- do.call("fn2",list(formula,data,...))
}

foo <- fn1(carb~optden,data=Formaldehyde)

fn2() clearly contains an error in subset. This example is just to illustrate the issue with traceback(), so please ignore the fact that this is just an lm() call. traceback() returns the following information:

6: stop("0 (non-NA) cases")
5: lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...)
4: lm(formula, data, subset = "some error", ...)
3: fn2(carb ~ optden, structure(list(carb = c(0.1, 0.3, 0.5, 0.6,

   0.7, 0.9), optden = c(0.086, 0.269, 0.446, 0.538, 0.626, 0.782    )), .Names = c("carb", "optden"), row.names = c("1", "2", "3",    "4", "5", "6"), class = "data.frame")) 2: do.call("fn2", list(formula, data, ...)) 1: fn1(carb ~ optden, data = Formaldehyde)

Is there a way for line 3 of the traceback output NOT to include all data and attributes?

In my case this would be helpful because if the data frame is large it can run off the terminal window, so it would make diagnostics easier with larger datasets.

Many thanks for your time,

Dan



System Info:
platform x86_64-redhat-linux-gnu
arch     x86_64
os       linux-gnu

system x86_64, linux-gnu
status
major 2
minor 1.1
year 2005
month 06
day 20
language R

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jul 07 12:30:46 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:18 EST