[R] Two problems

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Thu Apr 18 19:12:22 CEST 2002


"Ambrosini Alessandro" <klavan at tiscalinet.it> writes:

> 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
> 
> For example, the first row exspress that node a and node b are connected by
> a direct line.
> Can R transform this matrix in the first matrix that I wrote ? Are there any
> struments?

Use matrix indexing:

i <- matrix(c(1,2,
              1,3,
              2,1,
              3,1),ncol=2,byrow=T)

m <- matrix(0,3,3)
m[i] <- 1
m


> 2: Which is the max dimension of a matrix that R can use (1000X1000?,
> 500000X500000?)? What is the biggest dimension of a file that R can import?

It has to fit in available memory. On a 32 bit machine, you can only
address 4GB (and only if the OS allows), so in principle the workspace
holds 500 million double cells which would allow a 20000x20000 matrix.
However, you generally need to have room for several copies, so 5k x
5k sounds more realistic. I forget what current status is on 64-bit
architectures.

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