Hi folks, I have a matrix of 3 columns and 17 lines that represents a graph or a adjacency matrix. I have also a vector of 30 elements with some of the nodes of the graph repeated.
seems like: 1. matrix that represents a graph: 1 2 1 1 3 1 1 4 1 2 1 1 2 4 1 3 1 1 4 1 1 4 2 1 2. vector of nodes repeated: 1 1 1 1 1 2 2 3 3 1 1 4 4 4 4 Well, I have tried to do a code to take the repeated nodes and make a spam of the matrix above in a adjacency matrix representation and I get not sucess. The code seems like: mat_spam<-function(mat_rev,vet_adj){ i<-1 while (i<6) { j<-1 while (j<17) { m<-1 while (m<6) { if (mat_rev[i+1,m]==mat_rev[i, m+1]){ mat_rev[i+1,m+1]=0} else{if (mat_rev[i,m+1]==vet_adj[j,1] & mat_rev[i,m+2]==vet_adj[j,2]){ mat_rev[i+1,m+1]=1} else{mat_rev[i+1,m+1]=0}} m<-m+1} j<-j+1} i<-i+1} return(mat_rev)} Anyone has a sugestion how can I do this? The principal question is how to spam an adjacency matrix to a biggest one by repeating nodes that i am representing by a vector. Thanks a lot, Francisco Gildemir Ferreira da Silva 2010/5/2 <r-sig-geo-requ...@stat.math.ethz.ch> > Send R-sig-Geo mailing list submissions to > r-sig-geo@stat.math.ethz.ch > > To subscribe or unsubscribe via the World Wide Web, visit > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > or, via email, send a message with subject or body 'help' to > r-sig-geo-requ...@stat.math.ethz.ch > > You can reach the person managing the list at > r-sig-geo-ow...@stat.math.ethz.ch > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of R-sig-Geo digest..." > > > Today's Topics: > > 1. from idirisi to s-plus to r (Seth J Myers) > 2. please ignore IDRISI to R question from 3 min ago (Seth J Myers) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Sun, 2 May 2010 06:02:46 +0000 > From: Seth J Myers <sjmy...@syr.edu> > To: "r-sig-geo@stat.math.ethz.ch" <r-sig-geo@stat.math.ethz.ch> > Subject: [R-sig-Geo] from idirisi to s-plus to r > Message-ID: > < > 266cbfbfd14254478d52158ae6bf90170c324...@bl2prd0103mb038.prod.exchangelabs.com > > > > Content-Type: text/plain; charset="us-ascii" > > Hi, > > I use IDRISI as my main raster GIS program and R for stats. IDRISI has an > export to s-plus function that allows you to mask a raster file for sampling > and then export into a format that supposedly works with s-plus. What this > ends up being is a .txt file with spaces between adjacent columns but no > seeming rhyme or reason as far as column width (it varies seemingly > arbitrarily and IDRISI help is no help in this area). They are of fixed > width for each column, but the width is not consistent among columns. > > I know I could import IDRISI .rst files into R, but this is very wasteful > of memory as I only need a small % of large files. My questions are: 1) is > there an easier export format to move a sample of an IDRISI .rst file into > R? 2) is there a way to import a .txt file into R that will ignore > repetitive spacing? (meaning two columns can be separated by 1 or more > spaces but the number of spaces is not specified). I would just specify > column width for each column in each file, but I have many files with 43 > columns each, so I prefer to avoid brute force here. Thanks, Seth > > > ------------------------------ > > Message: 2 > Date: Sun, 2 May 2010 06:09:17 +0000 > From: Seth J Myers <sjmy...@syr.edu> > To: "r-sig-geo@stat.math.ethz.ch" <r-sig-geo@stat.math.ethz.ch> > Subject: [R-sig-Geo] please ignore IDRISI to R question from 3 min ago > Message-ID: > < > 266cbfbfd14254478d52158ae6bf90170c324...@bl2prd0103mb038.prod.exchangelabs.com > > > > Content-Type: text/plain; charset="us-ascii" > > I disobeyed my firm rule, never right emails without careful thought after > several hours of analysis and 3 beers on a saturday night ;) -Seth > > > > ------------------------------ > > _______________________________________________ > R-sig-Geo mailing list > R-sig-Geo@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > > > End of R-sig-Geo Digest, Vol 81, Issue 2 > **************************************** > [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo