[R] Matrix Another table
RMSOPS
ricardosousa2000 at clix.pt
Tue Mar 13 12:51:59 CET 2012
I have next table
source destine
3 3
7 7
6 6
3 4
4 4
4 3
3 3
3 3
3 3
3 3
3 4
4 4
4 3
3 4
4 3
I'm trying to create an array with the number of occurrences between the
source and destination. id_ap<-levels(factor(df$v_source))
num_AP<-length(levels(factor(df$v_source)))
mat<-matrix(data=NA,nrow=num_AP,ncol=num_AP,
byrow=TRUE,dimnames=list(id_ap,id_ap))
1 2 3 4 5 6 7
1 NA NA NA NA NA NA NA
2 NA NA NA NA NA NA NA
3 NA NA NA 4 NA NA NA 4
NA NA NA NA NA NA NA 5
NA NA NA NA NA NA NA 6
NA NA NA NA NA NA NA 7
NA NA NA NA NA NA NA
what better way to count the occurrences of the table, for example 3-4 = 4
times
Thanks
--
View this message in context: http://r.789695.n4.nabble.com/Matrix-Another-table-tp4468875p4468875.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list