Hi Chris, On Tuesday 16 December 2008, Chris Oldmeadow wrote: > Hi all, > > I have a very large binary vector, I wish to calculate the number of > 1's over sliding windows. > [...snip...]
Your function does not seem to function very well, could you please offer a self-contained, reproducible example? When writing a function, it is indicated not to use reserved commands like "seq" (which is a function itself, generating a sequence of numbers). In any case, I suspect you might want to take a look on the function "rle". See ?rle I hope this helps, Adrian -- Adrian Dusa Romanian Social Data Archive 1, Schitu Magureanu Bd. 050025 Bucharest sector 5 Romania Tel.:+40 21 3126618 \ +40 21 3120210 / int.101 Fax: +40 21 3158391 [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.