[R] grouping and counting in dataframe
zem
zmanolova at gmail.com
Sat Feb 26 23:10:28 CET 2011
sry,
new try:
tm<-c(12345,42352,12435,67546,24234,76543,31243,13334,64562,64123)
gr<-c(1,3,1,2,2,4,2,3,3,3)
d<-data.frame(cbind(time,gr))
where tm are unix times and gr the factor grouping by
i have a skalar for example k=500
now i need to calculate in for every row how much examples in the group are
in the interval [i-500;i+500] and i is the active tm-element, like this:
>d
time gr ct
1 12345 1 2
2 42352 3 0
3 12435 1 2
4 67546 2 0
5 24234 2 0
6 76543 4 0
7 31243 2 0
8 13334 3 0
9 64562 3 2
10 64123 3 2
i hope that was a better illustration of my problem
--
View this message in context: http://r.789695.n4.nabble.com/grouping-and-counting-in-dataframe-tp3325476p3326338.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list