title: How to set timestamp as an index for a data frame in R
body: <p>I have a dataframe called 'trial'. I have combined the Date and Time in the data frame to get a field which has timestamp as a POSIXct. I want to set this combined date time or the timestampas the index for my data frame 'trial' how can I do so? I have seen similar questions on this with no success.
  The code is as follows:</p>
  
  <pre><code> trial &lt;- read.csv("2018_05_04_h093500.csv", header=TRUE, skip = 16, sep=",")
   trial$Date &lt;- with(trial, as.POSIXct(paste(as.Date(Date, format="%Y/%m/%d"), Time)))
   dtPOSIXct &lt;- as.POSIXct(trial$Date )
   dtTime &lt;- as.numeric(dtPOSIXct - trunc(dtPOSIXct, "days"))
   class(dtTime) &lt;- "POSIXct"
  </code></pre>