Re: [R] simplification of code using stamp?

From: hadley wickham <h.wickham_at_gmail.com>
Date: Thu 26 Oct 2006 - 00:51:30 GMT

> I get the following, which is not what I am looking for.
>
> > test[1:10,]
> expert xx seeds run value
> 1 BW x0010 25 1 rsqs, slope, d.slope, intercept, d.intercept
> 2 BW x0010 25 2 rsqs, slope, d.slope, intercept, d.intercept
> 3 BW x0010 25 3 rsqs, slope, d.slope, intercept, d.intercept
> 4 BW x0010 25 4 rsqs, slope, d.slope, intercept, d.intercept
> 5 BW x0010 25 5 rsqs, slope, d.slope, intercept, d.intercept
> 6 BW x0010 28 1 rsqs, slope, d.slope, intercept, d.intercept
> 7 BW x0010 28 2 rsqs, slope, d.slope, intercept, d.intercept
> 8 BW x0010 28 3 rsqs, slope, d.slope, intercept, d.intercept
> 9 BW x0010 28 4 rsqs, slope, d.slope, intercept, d.intercept
> 10 BW x0010 28 5 rsqs, slope, d.slope, intercept, d.intercept

That's because stamp doesn't produce great output at the moment (have a look at the str(test) to see that you have a data frame containing a list of vectors)

The following code should put it a more reasonable form:

tidy <- function(x) {
  bind <- function(i) data.frame(x[i, -ncol(x),drop=FALSE], t(a$value[[i]]))   l <- lapply(1:nrow(x), bind)
  do.call(rbind.fill, l)
}

tidy(test)

(but unless you provide a reproducible example I can't be sure that it works with your data)

Regards,

Hadley



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 and provide commented, minimal, self-contained, reproducible code. Received on Thu Oct 26 20:28:22 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 26 Oct 2006 - 13:30:12 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.