Error undefined function in R ":=" : <p>Im writing an R code to calculate the average of a data point for every minute for my given data. </p>

<p>My data frame is</p>

<pre><code>TIME                              PRICE
2013-01-01 23:54:54               20133
2013-01-01 23:54:50               20133
2013-01-01 23:53:34               20134
2013-01-01 23:53:40               20131
2013-01-01 22:52:54               20131
2013-01-01 22:52:50               20132
</code></pre>

<p>I want my resultant data frame to have</p>

<pre><code>TIME                              PRICE
2013-01-01 23:54:00               20133
2013-01-01 23:53:00               20132.5
2013-01-01 23:52:00               20131.5
</code></pre>

<p>I used a code snippet to separate my data into hour and minute. </p>

<pre><code>trade_1[, c('Hour', 'Minute') := .(data.table::hour("TIME"), minute("TIME"))
+    ][, .(Avg = mean("PRICE")), .(Hour, Minute)]
</code></pre>

<p>using package <code>lubridate</code></p>

<p>I get the following error</p>

<pre><code>Error in `:=`(c("Hour", "Minute"), .(data.table::hour("TRADETIME"), minute("TRADETIME"))) : 
  could not find function ":="
</code></pre>

<p>Can someone please help me out? </p>

<p>I have already used <code>library(lubridate).</code> </p>
