0

I want to subset just one line of cor() matrix

when I run the cor() function, It gives me this result

ex)

   a  b  c  d  e
a  1  2  3  4  5
b  5  1  3  2  1
c  2  3  1  5  6
d  1  1  1  1  1
e  1  1  1  1  1

I only want this section

   a  b  c  d  e
a  1  2  3  4  5

or

  b  c  d  e
a 2  3  4  5

Any Suggestion?

I tried result[1, 1:5] but the result was

a  b  c  d  e
1  2  3  4  5
devdevsss
  • 15
  • 3
  • 1
    https://stackoverflow.com/questions/7352254/how-to-subset-matrix-to-one-column-maintain-matrix-data-type-maintain-row-colu – Ronak Shah Apr 10 '21 at 09:57
  • you can find the correlation of one variable against the others - [here](https://stackoverflow.com/questions/45892274/correlation-of-one-variable-to-all-the-other-in-r) – user20650 Apr 10 '21 at 11:06

1 Answers1

1

You could try result[1, 2:5, drop=FALSE]. The drop should let you retain the row name.

WilliamGram
  • 673
  • 3
  • 7