[R] Is there a way to map data from Binary format to Numerical numbers?

arun smartpink111 at yahoo.com
Sun Feb 1 15:55:54 CET 2015


Try

indx <- which(!!mat, arr.ind=TRUE)
v1 <-unname(sapply(split(indx[,2], indx[,1]),toString))

cat(paste(v1, collapse="\n"), sep="\n")
1, 2, 3, 6, 7, 8, 9
1, 2, 3, 6, 8, 9
1, 3, 4, 6, 7, 8, 9
1, 8
1, 3, 6, 7, 8, 9
1, 3, 4, 6, 8, 9
1, 3, 5, 9


A.K.

   



Hi,
Is there a way to map data from Binary format to Numerical numbers?

example:
I have text files, where each record consists of several items (9 items)
1, means item appear
0, means item absent

1,1,1,0,0,1,1,1,1
1,1,1,0,0,1,0,1,1
1,0,1,1,0,1,1,1,1
1,0,0,0,0,0,0,1,0
1,0,1,0,0,1,1,1,1
1,0,1,1,0,1,0,1,1
1,0,1,0,1,0,0,0,1


I want transform my data to numerical numbers in ascending order, such that when items is absent, i didn't print it, but keep increase the counter. for example, the above binary format will be: ,
1,2,3,6,7,8,9
1,2,3,6,8,9
1,3,4,6,7,8,9
1,8,
1,3,6,7,8,9
1,3,4,5,7,8
1,3,5,9



More information about the R-help mailing list