You got this strange behavior because variable y.var.1
is defined in your session (maybe you used function attach()
or just defined it as separate vector). If you just use y.var.1
in function acf()
then this variable from session is used. You should add X$
inside acf()
to use y.var.1
that is defined as one column of data frame data.1
.
dlply(data.1, .(ID), function(X) acf(X$y.var.1, na.action = na.pass))
$`1`
Autocorrelations of series ‘X$y.var.1’, by lag
0 1 2 3 4
1.000 0.446 -0.142 -0.447 -0.357
$`2`
Autocorrelations of series ‘X$y.var.1’, by lag
0 1 2 3 4
1.000 0.373 -0.084 -0.373 -0.416
$`3`
Autocorrelations of series ‘X$y.var.1’, by lag
0 1 2 3 4
1.000 0.377 -0.086 -0.381 -0.411