Hi, Does anyone know if R has the functionality to calculate a simple moving average. I cant seem to find it in the help menu. thanks, Wayne Dr Wayne R. Jones Statistician / Research Analyst KSS Group plc St James''s Buildings 79 Oxford Street Manchester M1 6SS Tel: +44(0)161 609 4084 Mob: +44(0)7810 523 713 KSS Ltd A division of Knowledge Support Systems Group plc Seventh Floor St James''s Buildings 79 Oxford Street Manchester M1 6SS England Company Registration Number 2800886 (Limited) 3449594 (plc) Tel: +44 (0) 161 228 0040 Fax: +44 (0) 161 236 6305 mailto:kssg@kssg.com http://www.kssg.com The information in this Internet email is confidential and may b... [[dropped]]
Wayne Jones wrote:>Does anyone know if R has the functionality to calculate a simple moving >average. I cant seem to find it in the help menu.does filter() do what you need? Morten
Sorry, a neccesary addition: filter in library ts. Morten
Try "filter" in package ts. Reid Huntsinger -----Original Message----- From: Wayne Jones [mailto:JonesW at kssg.com] Sent: Friday, March 07, 2003 9:37 AM To: r-help at stat.math.ethz.ch Subject: [R] Moving average Hi, Does anyone know if R has the functionality to calculate a simple moving average. I cant seem to find it in the help menu. thanks, Wayne Dr Wayne R. Jones Statistician / Research Analyst KSS Group plc St James's Buildings 79 Oxford Street Manchester M1 6SS Tel: +44(0)161 609 4084 Mob: +44(0)7810 523 713 KSS Ltd A division of Knowledge Support Systems Group plc Seventh Floor St James's Buildings 79 Oxford Street Manchester M1 6SS England Company Registration Number 2800886 (Limited) 3449594 (plc) Tel: +44 (0) 161 228 0040 Fax: +44 (0) 161 236 6305 mailto:kssg at kssg.com http://www.kssg.com The information in this Internet email is confidential and may b... [[dropped]]
Or look at the 'running' function in the gregmisc package. -Greg> -----Original Message----- > From: Huntsinger, Reid [mailto:reid_huntsinger at merck.com] > Sent: Friday, March 07, 2003 10:13 AM > To: 'Wayne Jones'; r-help at stat.math.ethz.ch > Subject: RE: [R] Moving average > > > Try "filter" in package ts. > > Reid Huntsinger > > -----Original Message----- > From: Wayne Jones [mailto:JonesW at kssg.com] > Sent: Friday, March 07, 2003 9:37 AM > To: r-help at stat.math.ethz.ch > Subject: [R] Moving average > > > Hi, > > Does anyone know if R has the functionality to calculate a > simple moving > average. I cant seem > to find it in the help menu. > > thanks, > > Wayne > > > Dr Wayne R. Jones > Statistician / Research Analyst > KSS Group plc > St James's Buildings > 79 Oxford Street > Manchester M1 6SS > Tel: +44(0)161 609 4084 > Mob: +44(0)7810 523 713 > > > > KSS Ltd > A division of Knowledge Support Systems Group plc > Seventh Floor St James's Buildings 79 Oxford Street > Manchester M1 6SS > England > Company Registration Number 2800886 (Limited) 3449594 (plc) > Tel: +44 (0) 161 228 0040 Fax: +44 (0) 161 236 6305 > mailto:kssg at kssg.com http://www.kssg.com > > > The information in this Internet email is confidential and > may b... [[dropped]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help >LEGAL NOTICE\ Unless expressly stated otherwise, this message is... [[dropped]]
Or try this:
(x is a vector, k is window-width for moving average)
moving.average <-
function(x, k) {
n <- length(x)
y <- rep(0, n)
for (i in (1+k):n)
y[i] <- mean(x[(i-k):i])
return(y)
}
Remko Duursma
--
On Fri, 7 Mar 2003 12:08:14
Warnes, Gregory R wrote:>Or look at the 'running' function in the gregmisc package.
>
>-Greg
>
>> -----Original Message-----
>> From: Huntsinger, Reid [mailto:reid_huntsinger at merck.com]
>> Sent: Friday, March 07, 2003 10:13 AM
>> To: 'Wayne Jones'; r-help at stat.math.ethz.ch
>> Subject: RE: [R] Moving average
>>
>>
>> Try "filter" in package ts.
>>
>> Reid Huntsinger
>>
>> -----Original Message-----
>> From: Wayne Jones [mailto:JonesW at kssg.com]
>> Sent: Friday, March 07, 2003 9:37 AM
>> To: r-help at stat.math.ethz.ch
>> Subject: [R] Moving average
>>
>>
>> Hi,
>>
>> Does anyone know if R has the functionality to calculate a
>> simple moving
>> average. I cant seem
>> to find it in the help menu.
>>
>> thanks,
>>
>> Wayne
>>
>>
>> Dr Wayne R. Jones
>> Statistician / Research Analyst
>> KSS Group plc
>> St James's Buildings
>> 79 Oxford Street
>> Manchester M1 6SS
>> Tel: +44(0)161 609 4084
>> Mob: +44(0)7810 523 713
>>
>>
>>
>> KSS Ltd
>> A division of Knowledge Support Systems Group plc
>> Seventh Floor St James's Buildings 79 Oxford Street
>> Manchester M1 6SS
>> England
>> Company Registration Number 2800886 (Limited) 3449594 (plc)
>> Tel: +44 (0) 161 228 0040 Fax: +44 (0) 161 236 6305
>> mailto:kssg at kssg.com http://www.kssg.com
>>
>>
>> The information in this Internet email is confidential and
>> may b... [[dropped]]
>>
>> ______________________________________________
>> R-help at stat.math.ethz.ch mailing list
>> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>>
>
>
>LEGAL NOTICE\ Unless expressly stated otherwise, this message is...
[[dropped]]
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>