search for: runningcount

Displaying 2 results from an estimated 2 matches for "runningcount".

2009 Jul 01
1
running count in data.frame
...$l column, and likewise for $pc and $p. It seems that $lc starts off OK until it gets to a 0 and then resets back to 0 which I don't want. The $pc counter never seems to count. I also get a warning message I don't understand so clearly I'm doing something very wrong here: > F1 <- RunningCount(F1) Warning messages: 1: In MyFrame$pc[pos] <- cumsum(as.integer(pos)) : number of items to replace is not a multiple of replacement length 2: In MyFrame$lc[pos] <- cumsum(as.integer(pos)) : number of items to replace is not a multiple of replacement length > F1 x y p l pc lc 1...
2009 Jul 01
2
?max (so far...)
...yFrame$lc<-0 MyFrame$pwin<-0 MyFrame$hp<-0 MyFrame$ll<-0 return(MyFrame) } BinPosNeg = function (MyFrame) { ## Positive y in p column, negative y in l column pos <- MyFrame$y > 0 MyFrame$p[pos] <- MyFrame$y[pos] MyFrame$l[!pos] <- MyFrame$y[!pos] return(MyFrame) } RunningCount = function (MyFrame) { ## Running count of p & l events pos <- (MyFrame$p > 0) MyFrame$pc <- cumsum(pos) pos <- (MyFrame$l < 0) MyFrame$lc <- cumsum(pos) return(MyFrame) } PercentWins = function (MyFrame) { MyFrame$pwin <- round((MyFrame$pc / (MyFrame$pc+MyFrame$...