[R] Expanding data ...

John Poulsen jpoulsen at zoo.ufl.edu
Sun Nov 16 13:31:04 CET 2008


Hello,

I have a dataset that has counts, but I need to expand the dataset so 
that each of the counts has its own line in the dataset (row) and is 
given and id.  It looks something like:

Site	Type	Cnt
1	"A"	3
1	"B"	0
2	"C"	2

I want the dataset to look like:

Site	Type	ID	
1	"A"	1
1	"A"	2	
1	"A"	3
1	"B"	0
2	"C"	1
2	"C"	2

I can do this using loops, but I was wondering if anyone knows a more 
efficient way of expanding the data on counts and giving id numbers.

Thanks for your help,
John



More information about the R-help mailing list