I would like to plot some ccf
plots for different values of an id
variable in a data.table
using R
. The issue is that ccf
returns a value that doesn't agree with data.table
. I don't care about the return value but just want to see the actual plot. Some code:
require(data.table)
x <- data.table(id=rep(1:10, each=10), a=rep(1:10,10), b=rep(10:1,10))
x[,ccf(a,b),by=id]
Error in `[.data.table`(x, , ccf(a, b), by = id) :
All items in j=list(...) should be atomic vectors or lists. If you are trying something like j=list(.SD,newcol=mean(colA)) then use := by group instead (much quicker), or cbind or merge afterwards.
Given this in the question :
I don't care about the return value but just want to see the actual plot.
then :
x[, {ccf(a,b);NULL}, by=id]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With