[R] adjacency matrix

Strumila, John John.Strumila at team.telstra.com
Fri Sep 22 00:06:56 CEST 2000


boy I get impressed with some of these responses.

John Strumila


>> Any idea how this can be done in R ?
> 
> Yep. Matrix indices:
> 
>  a<-c(5,2,2,3,3,2) 
>  b<-c(2,3,4,5,6,1,3,2,4,3,1,5,1,4,6,1,4)
> 
>  n<-length(a)              
>  M<-matrix(0,n,n)
>  M[cbind(rep(1:n,a),b)]<-1
> 
> -- 
>    O__  ---- Peter Dalgaard             Blegdamsvej 3  
>   c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
>  (*) \(*) -- University of Copenhagen   Denmark      Ph: 
> (+45) 35327918
> ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: 
> (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list