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

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to