[R] coerce matrix to number

2006-09-12 Thread Simone Gabbriellini
Dear List, how can I coerce a matrix like this [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0 1 1 0 0 0 [2,] 1 0 1 0 0 0 [3,] 1 1 0 0 0 0 [4,] 0 0 0 0 1 0 [5,] 0 0 0 1 0 0 [6,] 0 0 0 0 0 0 to be filled with numbers? this is the result of replacing some character (v,

Re: [R] coerce matrix to number

2006-09-12 Thread Marc Schwartz (via MN)
On Tue, 2006-09-12 at 18:42 +0200, Simone Gabbriellini wrote: Dear List, how can I coerce a matrix like this [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0 1 1 0 0 0 [2,] 1 0 1 0 0 0 [3,] 1 1 0 0 0 0 [4,] 0 0 0 0 1 0 [5,] 0 0 0 1 0 0 [6,] 0 0 0 0 0 0 to be

Re: [R] coerce matrix to number

2006-09-12 Thread Jacques VESLOT
if only 2 letters: (z==v)*1 else: lapply(z, function(x) as.numeric(as.character(factor(x,levels= c(d,v,w),labels=c(0,1,2) --- Jacques VESLOT CNRS UMR 8090 I.B.L (2ème étage) 1 rue du Professeur Calmette B.P. 245 59019 Lille

Re: [R] coerce matrix to number

2006-09-12 Thread Simone Gabbriellini
Marc, wpw, great, what a lot of solutions!!! thank you very much, simone Il giorno 12/set/06, alle ore 19:21, Marc Schwartz (via MN) ha scritto: On Tue, 2006-09-12 at 18:42 +0200, Simone Gabbriellini wrote: Dear List, how can I coerce a matrix like this [,1] [,2] [,3] [,4] [,5]