Try this: x_long <- reshape(x, direction = 'long', varying = 2:4, sep = '', idvar = 'V1', timevar = 'V') subset(x_long[order(x_long$V1),], V != "")
On Thu, May 20, 2010 at 2:13 PM, Mia Bengtsson <mia.bengts...@bio.uib.no>wrote: > 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.bengts...@bio.uib.no > > ______________________________________________ > R-help@r-project.org 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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org 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.