Skip to content
Prev 305450 / 398506 Next

calculate within-day correlations

On Sep 13, 2012, at 7:09 PM, Rui Barradas wrote:

            
Probably will get better results with :  use="complete.obs")
identical(with( Q_use, split(idx1, format(date, "%Y-%m-%d") ) ), with( SC_use, split(idx2, format(date, "%Y-%m-%d") ) ) )
[1] TRUE
2002-03-28 2002-03-29 2002-03-30 2002-03-31 
-0.4916499 -0.6085098         NA         NA 

sapply( with( Q_use, split(idx1, format(date, "%Y-%m-%d") ) ), function(idxs) cor( Q_use[idxs, "Q"], SC_use[idxs, "SC"], use="complete.obs")  )

2002-03-28 2002-03-29 2002-03-30 2002-03-31 
-0.4916499 -0.6085098 -0.1489898         NA