An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20101201/1ca4a3fd/attachment.pl>
read a matrix to find a value
2 messages · Barroso, Judit, Phil Spector
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.