Re: [R] manipulate a matrix

From: jim holtman <jholtman_at_gmail.com>
Date: Mon, 25 Jun 2007 12:39:46 -0400

Is this what you want?

> x

     [,1] [,2] [,3] [,4] [,5]

[1,]    1    6   11   16   21
[2,]    2    7   12   17   22
[3,]    3    8   13   18   23
[4,]    4    9   14   19   24
[5,]    5   10   15   20   25

> cbind(row=as.vector(row(x)), col=as.vector(col(x)), value=as.vector(x))
row col value [1,] 1 1 1 [2,] 2 1 2 [3,] 3 1 3 [4,] 4 1 4 [5,] 5 1 5 [6,] 1 2 6 [7,] 2 2 7 [8,] 3 2 8 [9,] 4 2 9 [10,] 5 2 10 [11,] 1 3 11 [12,] 2 3 12 [13,] 3 3 13 [14,] 4 3 14 [15,] 5 3 15 [16,] 1 4 16 [17,] 2 4 17 [18,] 3 4 18 [19,] 4 4 19 [20,] 5 4 20 [21,] 1 5 21 [22,] 2 5 22 [23,] 3 5 23

[24,] 4 5 24
[25,] 5 5 25
>

On 6/25/07, Jon Hak <Jon_Hak_at_natureserve.org> wrote:
>
> I have read everything I can find on how to manipulate a results matrix in
> R and I have to admit I'm stumped. I have set up a process to extract a
> dataset from ArcGIS to compute a similarity index (Jaccards) in Vegan. The
> dataset is fairly simple, but large, and consists of rows = sample area, and
> columns = elements. I've been able to view the results in R, but I want to
> get the results out to a database and a matrix that is 6000-rows x
> 6000-columns can be very difficult to manipulate in Windows XP. I would to
> rotate the matrix so that the output would look like the old condensed
> format in programs like Conoco. Ideally, I would like format to look
> something like this;
>
>
> Site-row Site-col Jaccard
> 1 1 1
> 1 2 .9
> 1 3 .6
> 2 1 .9
> 2 2 1
> 2 3 .75
>
> Thanks for any help,
>
>
>
>
> ***********************************************************
> John Hak
> Senior GIS Analyst/Sr. Ecologist
> NatureServe
> 4001 Discovery Drive
> Boulder, CO 80303
> (703) 797-4809
>
> There is perhaps no better demonstration of the folly of human conceits
> than this distant image of our tiny world. To me, it underscores our
> responsibility to deal more kindly with one another, and to preserve and
> cherish the pale blue dot, the only home we've ever known. --Carl Sagan
>
>
> ______________________________________________
> R-help_at_stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

	[[alternative HTML version deleted]]

______________________________________________
R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Mon 25 Jun 2007 - 17:21:58 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 25 Jun 2007 - 17:32:21 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.