Message-ID: <alpine.DEB.2.00.1012011436260.14696@springer.Berkeley.EDU>
Date: 2010-12-01T22:37:57Z
From: Phil Spector
Subject: read a matrix to find a value
In-Reply-To: <19CAA898C7475A49B1221E1EAA3564B58DC3A010A4@EXCMS.msu.montana.edu>
Judit -
Does this example provide any insight?
> pop <- matrix(0,7,7)# Population matrix when t==0
> pop[sample(1:length(pop),1)] <-1 #Population matrix when t==1
> which(pop!=0,arr.ind=TRUE)
row col
[1,] 3 4
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spector at stat.berkeley.edu
On Wed, 1 Dec 2010, Barroso, Judit wrote:
> Dear all of you,
>
> I would like if someone can help me to know how I can read a matrix looking for positions in the matrix that are not null.
> I have a matrix with most of the "cells" or "positions" null, I am trying to know the invasion power of a plant (number 1 in the matrix when t==1).
> I would like to continue the model writing some condition when the value of the matrix in not null, but I don't know what function or loop I have to use to find the values > than 0 for the next step.
>
> pop <- matrix(0,7,7)# Population matrix when t==0
> pop[sample(1:length(pop),1)] <-1 #Population matrix when t==1
>
> Thanks a lot,
> Judit
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org 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.
>