Hello everyone,
  
   I'm writting a little script that will read a matrix from a file
  
  i.e.
  
  0,.11,.22,.4
  .11,0,.5,.3
  .22,.5,0,.7
  anb so on
  
  and will then calculate some standard stats for nets (i.e. centralization, 
degree, etc).
  
    So far I have opened the file and read the contents, however I' m using 
readLines(filename)  
   to read the file and it returns it as one big String with no divitions. I 
tried using 
  strsplit(String)
  to split it but eventhough is working I'm not able to put the output of the 
above into a matrix. 
   
   Below is an example of what I have done
  
  
  > INfile<-file("mTest.txt", "r")
  > readLines(INfile)->matrix
  > matrix
  [1] "1, 2, 3"
  > strsplit(matrix, ",")->splitLine
  > splitLine
  [[1]]
  [1] "1"  " 2" " 3"
  
  > netMatrix <-matrix(c(splitLine), nrow=1,ncol=3)
  > netMatrix
       [,1]         [,2]         [,3]       
  [1,] Character,3 Character,3 Character,3
  
  
   Does anyone have an idea how can I read a matrix and store it in the form of 
a matrix.
  
  thks
  
  -Cuau Vital
  
  
                
---------------------------------

        [[alternative HTML version deleted]]

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to