0

Link to the example of the matrix I am trying to work with

The image is an example of the output that I get after running a method (icd9_comorbid_quan_deyo()) in R-package ('icd') with a dataframe as input.

In the index(?) column are the identifier for the attributes (12345, 12346, ...). Is there a way to extract these numbers (12345, 12346, ...) and define them as a separate column when I convert the matrix into a dataframe?

I am quite new to R and seem to be stuck on this problem. I apologize in advance for any incorrect terms.

Thank you.

  • 1
    Can you please paste the results of `dput()` on your matrix so that others can attempt to reproduce this issue? – Stedy Dec 21 '16 at 18:31
  • Looks like it is the rownames. then `df1$newColumn <- row.names(df1)` if it is a matrix, then `cbind(m1, newColumn = as.numeric(row.names(m1)))` – akrun Dec 21 '16 at 18:31
  • Don't post pictures of data. Try to post a minimal [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) of your data object so we can more clearly see what's going on. See the provided link for details. – MrFlick Dec 21 '16 at 18:34

1 Answers1

0

Thank you for the advices. I will make sure to post a question with reproducible example next time. As far as this question goes, I tried the methods suggested by @akrun by first turning matrix into a dataframe and it successfully extracted the desired identifiers.