Generate new matrix by removing a particular column and row

Asked

Viewed 59 times

1

I wonder if there is any R function that I can generate a new matrix by deleting a certain column and row.

Matriz_1 
      [,1]  [,2]  [,3]  [,4]  [,5]  [,6]
[1,]   0.0 136.6 123.7 124.3 128.0 123.7
[2,] 136.6   0.0   8.8  15.9   5.7  15.4
[3,] 123.7   8.8   0.0   7.5   4.6   6.9
[4,] 124.3  15.9   7.4   0.0  11.7   1.6
[5,] 128.0   5.7   4.6  11.8   0.0  11.2
[6,] 123.7  15.3   6.9   1.6  11.2   0.0

This is my data:

Matrix_1 <- structure(c(0, 136.6, 123.7, 124.3, 128, 123.7, 136.6, 0, 8.8, 
  15.9, 5.7, 15.4, 123.7, 8.8, 0, 7.5, 4.6, 6.9, 124.3, 15.9, 7.4, 
  0, 11.7, 1.6, 128, 5.7, 4.6, 11.8, 0, 11.2, 123.7, 15.3, 6.9, 
  1.6, 11.2, 0), .Dim = c(6L, 6L))

I want the new matrix to have only points larger than 125 (I want to analyze by line 1).

In this case I would remove columns 3, 4 and 6, and also lines 3, 4 and 6, resulting in

       [,1]   [,2]  [,5]  
[1,]   0.0  136.6  128.0 
[2,] 136.6   0.0     5.7 
[5,] 128.0   5.7     0.0  

In short, I want to analyze my first row...I gave an example where I want to delete the columns from the matrix that have a value higher than 125, analyzing row 1. After deleting the columns delete the corresponding row. example: if I deleted column 4, delete row 4. But I want to preserve the indexes and then save in a vector the remaining indexes Aram and my new matrix "filtered".

  • Even with my issue, the question doesn’t make much sense. What does "I want the new matrix to have only points larger than 125" mean? What is a dot in a matrix? And even if only columns with observations larger than 125 in row 1 are maintained, what column 1 does in the result, if its value is 0.0?

  • I’m sorry if I didn’t express myself well. I’ll try again. I want to analyze my first row...I gave an example where I want to delete the columns that have a value higher than 125, analyzing row 1. After deleting the columns delete the corresponding row. example: if I deleted column 4, delete row 4. But I want to preserve the indexes and then save in a vector the remaining indexes and my new matrix "filtered".

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.