Re: [R] Change a value in a matrix randomly

2010-11-09 Thread Steve Taylor
A=matrix(0,nr=3,nc=4) A[sample(prod(dim(A)),1)]=1 >>> From: "Barroso, Judit" To:"r-help@r-project.org" Date: 10/Nov/2010 11:12a Subject: [R] Change a value in a matrix randomly I have a matrix of ceros, for example: 0 0 0

Re: [R] Change a value in a matrix randomly

2010-11-09 Thread Peter Alspach
Peter Alspach > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of Barroso, Judit > Sent: Wednesday, 10 November 2010 10:50 a.m. > To: r-help@r-project.org > Subject: [R] Change a value in a matrix randomly >

[R] Change a value in a matrix randomly

2010-11-09 Thread Barroso, Judit
I have a matrix of ceros, for example: 0 0 0 0 0 0 0 0 0 0 0 0 And I would like that one of these values turn into 1, for example if one condition is got, but not in a concrete posi