A user has the following matrix but wants to select the column which has a value of 11.how to do that?

965    Asked by IraJoshi in Data Science , Asked on Nov 18, 2019
Answered by Nitin Solanki

one two three four

[1,] 1 6 11 16

[2,] 2 7 12 17

[3,] 3 8 11 18

[4,] 4 9 11 19

[5,] 5 10 15 20

Now to extract submatrix having column ‘three’ of value 11 we can do the following

m[m[, "three"] == 11,]

    one two three four

[1,] 1 6 11 16

[3,] 3 8 11 18

[4,] 4 9 11 19



Your Answer

Interviews

Parent Categories