A=matrix(0,nr=3,nc=4)
A[sample(prod(dim(A)),1)]=1

>>> 

From: "Barroso, Judit" <judit.barroso@exchange.montana.edu>
To:"r-help@r-project.org" <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              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 position if not randomly.
Could you indicate me the code to can get it?

Thanks in advance,
Judit Barroso

[[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help 
PLEASE do read the posting guide http://www.R ( http://www.r/ )-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

	[[alternative HTML version deleted]]

