[BioC] replacing values using their indices
Matthew McCall
mccallm at gmail.com
Sat Feb 12 15:41:29 CET 2011
> mydata
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 1 2 3 4 1 6
[2,] 2 3 4 5 6 6
[3,] 3 5 6 2 7 0
> myindices
[,1] [,2]
[1,] 1 2
[2,] 1 5
[3,] 3 5
> mydata[myindices] <- NA
> mydata
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 1 NA 3 4 NA 6
[2,] 2 3 4 5 6 6
[3,] 3 5 6 2 NA 0
On Sat, Feb 12, 2011 at 7:09 AM, Daniel M. <danielmessay at yahoo.com> wrote:
> Hello,
>
> I was trying to replace some values in a data matrix using their index as a
> reference by NA.
> Say i have the following data matrix
>
> mydata
>
> 1 2 3 4 1 6
> 2 3 4 5 6 6
> 3 5 6 2 7 0
>
> and i have also
> myindices
> 1 2
> 1 5
> 3 5
>
> that refers to the data values above, for example 1 2 means that row 1 and
> column 2, that has a value of 2 in mydata, 1 5 means the value 1 in the first
> row and 5th col.
>
> I want to replace those index values as in "myindices" from "mydata" by NA's.
>
> Is there anyone who can suggest me as to how to do this, please?
>
> Thank you
>
> Daniel
>
>
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor
>
--
Matthew N McCall, PhD
112 Arvine Heights
Rochester, NY 14611
Cell: 202-222-5880
More information about the Bioconductor
mailing list