How to iterate through the columns of a data frame efficiently? : <p>So, <code>data</code> is a data frame consists of many columns, and one of which called <code>lpep_pickup_datetime</code> has date and time in the format of "01/01/2016 12:39:36 AM"</p>

<p>I want to analyze these data by date and time, so I am trying to create a new column named <code>pickup_date</code> and one named <code>pickup_time</code> with AM or PM information.</p>

<p>I have used the strsplit function to split the string into the following form: c("01/01/2016", "12:29:24", "AM"), and I am trying to create the aforementioned columns out of this data.</p>

<p>I have wrote the following code:</p>

<pre><code>data$lpep_pickup_datetime=strsplit(data$lpep_pickup_datetime, " ")

data$pickup_date=data$lpep_pickup_datetime[[1]][1]


for (i in seq(1,90181))
{
  data$pickup_time[i]=data$lpep_pickup_datetime[[i]][2]  
}
</code></pre>

<p>This is gravely inefficient, as it takes too long to iterate through 90181 rows of data. Is there a better way to accomplish this task?</p>

<p>Thanks.</p>
