0
M = matrix(data = 1:9, nrow = 3, ncol = 3)
print (M)

##      [,1] [,2] [,3]
## [1,]    1    4    7
## [2,]    1    4    8
## [3,]    3    6    9

I wanna check that elements in row [1,] are equal to elements at row[2,]. Or which elements at row[1,] are equal to elements at column[,3], for example.

Ana Paula
  • 1
  • 3
  • 1
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Exactly what kinds of duplicates are you looking for? Something like this might help: https://stackoverflow.com/questions/12495345/find-indices-of-duplicated-rows – MrFlick Aug 01 '20 at 05:02
  • I put an image, I need to check the interactions beetween indexes left and indexes from right side. – Ana Paula Aug 01 '20 at 05:18
  • Please don't use images when sharing data. We can't copy/paste into R for testing. We also don't need your entire data, just a small, reproducible example that makes it clear what you are trying to do. – MrFlick Aug 01 '20 at 05:19
  • # Create matrix do store indexes # Search for the sequences # Search in left sequences # Search in right sequences # mark repeated sequences with idx index # Now we will search for all righ sequences # Search for all right sequences # give an index to the sequence we are looking for # mark repeated sequences with idx index # Put back the column representing the interaction #also check for repeated sequences in the original file – Ana Paula Aug 01 '20 at 06:10
  • I wanna check for repeated sequences in the file. So, which command I will use? – Ana Paula Aug 01 '20 at 06:28
  • I would avoid reassigning the result back to your same variable name. General approach would be to make a copy of the matrix (can be by reference) shifted forward by one and down by one, and then compare `matrixorig == matrixshift` (w/o the `not`, etc) this will give you columns of true/false values and you can look for any `True` entries all the way down a column. – beroe Aug 01 '20 at 06:51
  • As mentioned, if you post a little 4x4 example it will make it easier for us to give a concrete solution. – beroe Aug 01 '20 at 06:52
  • Ok, i fixed it. Sorry for my incomprehension, I'm begginer here. – Ana Paula Aug 01 '20 at 16:58

0 Answers0