[R] R vector

2013-06-11 Thread felice
hello, when i use the function rowMeans, which is sum/n, can i divide it in 2 parts, - Sum(just positive values)/n and Sum(just negative values)/n. i need both for my regression but dont know how to do it. for example we have the matrix 1 1 -1 -1 - rowMeans([1:3 , 2]) just positive - 1 1

[R] RCOde need urgent HELP

2013-06-07 Thread felice
hey i need help with a case in my R project. i have a vector Rt with returns from day 1 till day t now i want to form a new vector r= which is rt = Xt − Xt−1 then i want to definde positive and negative aggregates r(n)+ _t= 1/n (rt +...+rt−n) I {(rt+...+ rt−n) ≥0} r(n)− _t= 1/n (rt +...+rt−n)