Well, I have no idea how to get from one to the other. There's col1 and col2 but no var1 var2 var3, etc. I thought perhaps col1 was the row index and col2 was the column index, but that doesn't match up either, and not all the cell values are 1.
So you will need to explain more clearly what you intend. Meanwhile, you might try reshape, or perhaps crosstab from the ecodist package. Sarah On Mon, Jan 25, 2010 at 5:39 PM, Lisa <lisa...@gmail.com> wrote: > > Dear all, > > I have a dataset that looks like this: > > x <- read.table(textConnection("col1 col2 > 3 1 > 2 2 > 4 7 > 8 6 > 5 10"), header=TRUE) > > I want to rewrite it as below: > > var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 > 1 0 1 0 0 0 0 0 0 0 > 0 2 0 0 0 0 0 0 0 0 > 0 0 0 1 0 0 1 0 0 0 > 0 0 0 0 0 1 0 1 0 0 > 0 0 0 0 1 0 0 0 0 1 > > Can anybody please help how to get this done? Your help would be greatly > appreciated. > > Lisa > -- Sarah Goslee http://www.functionaldiversity.org ______________________________________________ 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.