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
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
>
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
3 matches
Mail list logo