replacing values using their indices
1
0
Entering edit mode
Daniel M. ▴ 20
@daniel-m-4380
Last seen 9.6 years ago
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]]
• 806 views
ADD COMMENT
0
Entering edit mode
@matthew-mccall-4459
Last seen 4.9 years ago
United States
> 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
ADD COMMENT

Login before adding your answer.

Traffic: 776 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6