[R] swapping with data.frame

Wolski wolski at molgen.mpg.de
Tue Jun 1 20:03:03 CEST 2004


Hi!
U can use.

rbind(t1,t2,t3)

Sincerely
Eryk

*********** REPLY SEPARATOR  ***********

On 6/1/2004 at 10:55 AM Randy Zelick wrote:

>Hi there,
>
>I have some data which are convenient to enter as lists. For example:
>
>t1<-list(fname="animal1",testname="hyla",dspkr="left",res1=39.7,res2=15.0)
>t2<-list(fname="animal1",testname="bufo",dspkr="left",res1=14.4,res2=56.1)
>t3<-list(fname="animal2",testname="hyla",dspkr="right",res1=22.6,res2=11.8)
>
>I would like to generate a dataframe, but *not* the way this approach
>works...
>
>fdf<-data.frame(t1,t2,t3)
>
>fdf
>
>    fname testname dspkr res1 res2   fname testname dspkr res1 res2 ...
>1 animal1     hyla  left 39.7   15 animal1     bufo  left 14.4 56.1 ...
>
>
>Instead, what I would like is:
>
>     fname   testname   dspkr   res1    res2
>
>t1 animal1       hyla    left   39.7    15.0
>t2 animal1       bufo    left   14.4    56.1
>t3 animal2       hyla   right   22.6    11.8
>
>
>or this would be fine too...
>
>    x   fname   testname   dspkr   res1    res2
>
>1  t1 animal1       hyla    left   39.7    15.0
>2  t2 animal1       bufo    left   14.4    56.1
>3  t3 animal2       hyla   right   22.6    11.8
>
>Is there a practical (hopefully simple) way to do this?
>
>Thanks,
>
>=Randy=
>
>R. Zelick				email: zelickr at pdx.edu
>Department of Biology			voice: 503-725-3086
>Portland State University		fax:   503-725-3888
>
>mailing:
>P.O. Box 751
>Portland, OR 97207
>
>shipping:
>1719 SW 10th Ave, Room 246
>Portland, OR 97201
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html



Dipl. bio-chem. Eryk Witold Wolski    @    MPI-Moleculare Genetic   
Ihnestrasse 63-73 14195 Berlin       'v'    
tel: 0049-30-83875219               /   \    
mail: wolski at molgen.mpg.de        ---W-W----    http://www.molgen.mpg.de/~wolski




More information about the R-help mailing list