# [R] simplification of code using stamp?

Rainer M Krug RKrug at sun.ac.za
Thu Oct 26 08:44:35 CEST 2006

```hadley wickham wrote:
>> 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)
Thanks Hadley - I'll look at the code.

>
> (but unless you provide a reproducible example I can't be sure that it
>
> Regards,
>

--
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:		+27 - (0)72 808 2975 (w)
Fax:		+27 - (0)21 808 3304
Cell:		+27 - (0)83 9479 042

email:	RKrug at sun.ac.za
Rainer at krugs.de

```