[R] Two problems

Agustin Lobo alobo at ija.csic.es
Fri Apr 19 11:31:58 CEST 2002


On Thu, 18 Apr 2002, Ambrosini Alessandro wrote:

> Hello! Two questions:
> 
> 1: I have to import a matrix of adjacency from a file of a software that is
> not R (for example "bloc notes" of Windows). The problem is that the matrix
> is not in the explicit form as
>  0 1 1
>  1 0 0
>  1 0 0
> but it is a scattered matrix where in each row there are two nodes that have
> a direct path.
> The matrix is
> 
>  a   b
>  a   c
>  b   a
>  c   a
> 

I would use table():

> d1 <- c("a","a","b","c")
> d2 <- c("b","c","a","a")
> table(d1,d2)
   d2
d1  a b c
  a 0 1 1
  b 1 0 0
  c 1 0 0


But is this not a very unefficient way of storing adjacencies?

Agus

Dr. Agustin Lobo
Instituto de Ciencias de la Tierra (CSIC)
Lluis Sole Sabaris s/n
08028 Barcelona SPAIN
tel 34 93409 5410
fax 34 93411 0012
alobo at ija.csic.es




-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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