[R] Two problems
David A Richmond
richmond at saintmarys.edu
Thu Apr 18 21:11:39 CEST 2002
question 1:
Try this:
> list <- cbind(c(1,1,2,3),c(2,3,1,1))
> list
[,1] [,2]
[1,] 1 2
[2,] 1 3
[3,] 2 1
[4,] 3 1
> mat <- matrix(0,max(list),max(list))
> mat[list] <- 1
> mat
[,1] [,2] [,3]
[1,] 0 1 1
[2,] 1 0 0
[3,] 1 0 0
Now you just need to figure out how to get R to read an ascii file, and
convert the a's and b's to 1's and 2's etc. (I don't know how to do this
off the top of my head, but you might look at "read" and look for some
kind of recoding function)
question2:
I believe the dimension size limited only by available memory.
dave r.
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
>
> 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?
>
> 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?
>
> Thank you so much.
> Alessandro
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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