search for: diffp

Displaying 1 result from an estimated 1 matches for "diffp".

Did you mean: diff
2012 Jan 06
4
data.frame: temporal complexity
Hello, I created a data.frame which contains two columns: df$P (Power) et df$DateTime (time). I'd like to add a new column df$diffP (difference of Power between T and T-2). I made a loop : for (i in 3:length(df$DateTime)){ df$diffP[i] = df$P[i] - df$P[i-2] } execution time result is unaceptable: 24s !! Is there any way to reduce complexity about O(n) ? for example 2 or 3s (10s maxi) Does anybody find better than ~24s ?...