[R] Res: convert table

From: Milton Cezar Ribeiro <milton_ruser_at_yahoo.com.br>
Date: Mon, 17 Dec 2007 14:33:41 -0800 (PST)


Ciao Giovanni,

Try this.

x<-matrix(sample(0:4,25,replace=T),nc=5) x
x[x>0]<-1
x

Miltinho
uno capoeirista brasiliano

Dear R user, a very simple question:
I have a table like this:

coor v1 v2 v3
x1 12 33 123
x2 1 123
x3 12
x4 33 1

and I'd like to tranform this matrix in presence/absence data.frame

coor 1 12 33 123
x1 0 1 1 1
x2 1 0 0 1
x3 0 1 0 0
x4 1 0 1 0

Could you suggest me a direct way to do this? Thank you
Giovanni



R-help_at_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.

 para armazenamento!

        [[alternative HTML version deleted]]



R-help_at_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. Received on Mon 17 Dec 2007 - 22:37:12 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 17 Dec 2007 - 23:30:19 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.