title: R Using index of rows for merging file
body: <p>I'm working with the survival library in R. I used residuals() on a survival object, which nicely outputs the residuals I want.</p>
  <p>My question is on how R treats its row indexes.</p>
  <p>Here is a sample data set. My goal is to merge them back together.</p>
  <p>Data Frame:</p>
  <pre><code>&gt; 1 - .2
  &gt; 2 - .4
  &gt; 3 - .6
  &gt; 4 - .8
  </code></pre>
  <p>Output:</p>
  <pre><code>&gt; 1 - .2X
  &gt; 2 - .4X
  &gt; 4 - .8X
  </code></pre>
  <p>The output is a subset of the input (some data couldn't be processed). What I'd like is to add this new list back to the original input file to plot and run regressions, etc.</p>
  <p>I don't know how to access the row indexes outside of the simple df[number] command. I think my approach to doing this is a bit prehistoric; I write.table() the objects which turns their row number into an actual printed column, and then go back and merge based on this new  key. I feel like there is a smarter way then to write out and read back in the files. Any suggestions on how?</p>
  <p>I hope this isn't a duplicate, as I looked around and couldn't quite find a good explanation on row indices.</p>
  <p>Edit:</p>
  <p>I can add column or row names to a data frame, but this results in a NULL value if done to a one dimensional object (my output file). The one dimensional object just has a subset of rows that I can't access.</p>
  <blockquote>
  <p>rownames(res)</p>
  <p>NULL</p>
  </blockquote>