[R] reshaping data

Mia Bengtsson mia.bengtsson at bio.uib.no
Thu May 20 19:13:37 CEST 2010


Hello,

I am a relatively new R-user who has a lot to learn. I have a large dataset that is in the following dataframe format:

red		A	B	C
green	D
blue	E	F

Where red, green and blue are "species" names and A, B and C are observations (corresponding to DNA sequences). Each observation can only belong to one species. I would like to list the observations in one column, with the species they belong to in the next. Like this:

A	red
B	red
C	red
D	green
E	blue
F	blue

I have tried using reshape() and stack() but I cannot get my head around it. Any help is highly appreciated!

Thanks in advance,
__________________________________

Mia Bengtsson, PhD-student
Department of Biology
University of Bergen
+47 55584715
+47 97413634
mia.bengtsson at bio.uib.no



More information about the R-help mailing list