Search code examples
rdata-analysis

Plotting matrix values from an interval


I have a matrix of many-many scaled values. It's a (2x500000) matrix.

I need to plot the matrix limited on [0.5, 0.6] × [0.0, 0.1]. And every column of the resulting matrix is interpreted as a point in R^2.

Could you tell me please, doest it mean, that my columns must be vectors like (0.502, 0.098), (0.534, 0.0423) etc.?

If yes, how can I subset exactly that kind of columns (part of the matrix)?

Thank you very much in advance for your help!


Solution

  • If your matrix is mat, this will subset the columnas that you want:

    mat[,which(mat[1,] >= 0.5 &
               mat[1,] <= 0.6 & 
               mat[2,] >= 0 & 
               mat[2,] <= 0.01)]