title: Set a Data Frame Column as the Index of R data.frame object
body: <p>Using R, how do I make a column of a dataframe the dataframe's index? Lets assume I read in my data from a .csv file. One of the columns is called 'Date' and I want to make that column the index of my dataframe.</p>
  
  <p>For example in Python, NumPy, Pandas; I would do the following:</p>
  
  <pre><code>df = pd.read_csv('/mydata.csv')
  d = df.set_index('Date')
  </code></pre>
  
  <p>Now how do I do that in R?</p>
  
  <p>I tried in R:</p>
  
  <pre><code>df &lt;- read.csv("/mydata.csv")
  d &lt;- data.frame(V1=df['Date'])
  # or
  d &lt;- data.frame(Index=df['Date'])
  
  # but these just make a new dataframe with one 'Date' column. 
  #The Index is still 0,1,2,3... and not my Dates.
  </code></pre>