[R] simplification of code using stamp?
hadley wickham
h.wickham at gmail.com
Thu Oct 26 02:51:30 CEST 2006
> 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
More information about the R-help
mailing list