search for: rollmean

Displaying 20 results from an estimated 54 matches for "rollmean".

2006 Jul 20
3
How do I modify an exported function in a locked environment?
...vn rev 38247 language R version.string Version 2.3.1 (2006-06-01) > I am trying to learn how to modify functions in a locked environment. For an example, suppose I'm using the package "zoo". zoo contains function "rollmean.default" > rollmean.default function (x, k, na.pad = FALSE, align = c("center", "left", "right"), ...) { x <- unclass(x) n <- length(x) y <- x[k:n] - x[c(1, 1:(n - k))] y[1] <- sum(x[1:k]) rval <- cumsum(y)/k if (na...
2006 Jul 20
3
How do I modify an exported function in a locked environment?
...vn rev 38247 language R version.string Version 2.3.1 (2006-06-01) > I am trying to learn how to modify functions in a locked environment. For an example, suppose I'm using the package "zoo". zoo contains function "rollmean.default" > rollmean.default function (x, k, na.pad = FALSE, align = c("center", "left", "right"), ...) { x <- unclass(x) n <- length(x) y <- x[k:n] - x[c(1, 1:(n - k))] y[1] <- sum(x[1:k]) rval <- cumsum(y)/k if (na...
2008 Jul 09
2
rollmean()
Hello, I am trying to calculate a 31 day running mean in some temperature data along ROWS. Rollmean() works great along columns, but how do I perform this same action on my rows? The data is a matrix of 365 columns (days of the year) by 5,000 rows (lat/long coordinates). I would like to perform a 31 day running mean along the 365 days. I am new to R so any help would be greatly appreciated! Th...
2010 Jan 02
1
Question on Reduce + rollmean
Hello useRs, I'd like to perform a moving average on the dataset, xx. I've tried combining the functions Reduce and rollmean but it didn't work. > r <- function(n) rollmean(n, 2) # where 2 = averaging interval > output < - Reduce("r", x) Error in f(init, x[[i]]) : unused argument(s) (x[[i]]) Is there anything wrong with the code in the first place? where > x [[1]] V1 V2 V3 [1,] 1...
2008 Jul 22
1
rollmean and stl
I need to investigate how rollmean and the trend returned from stl differ. I am trying to find out exactly what the trend part of stl is (I have just started coding in R and do not know fortran). I need to extract this because it will be used in further calculations, and it needs to be verified to make sure that I am using the righ...
2008 Feb 13
4
rolling sum (like in Rmetrics package)
Hello, I'm new to R and would like to know how to create a vector of "rolling sums". (I have seen the Rmetrics package and the rollMean function and I would like to do the same thing except Sum instead of Mean.) I imagine someone has done this, I just can't find it anywhere. Example: x <- somevector #where x is 'n' entries long #what I would like to do is: x1 <- x[1:20] output1 <- sum(x1) x2 <- x[...
2010 Aug 20
3
rollmean help (or similar function)
I am working on a simple pilot project comparing the capability of SQL, SAS and R to perform a rolling mean per the following instructions. I have completed the SQL and SAS analysis, so now it's R's turn. Calculate mean values of x (x=count) for each date in the dataset where mean = the average count of days [t-9] through day [t-3] for each date/illness combination. Dataset aggpilot
2008 Jan 07
5
moving or running average
Hi all R users, Can anyone please let me know how to do the moving average with R? With regards, Abu _________________________________________________________________ Free games, great prizes - get gaming at Gamesbox.
2012 Mar 03
4
Sliding a Window in R
Dear all, I am having a vector of around 300.000 elements and I Want to slide fast a window from the first element until the last-Windowsize what I have so far is the following for statement:  for (i in 1:(length(data[,1]) - windowSize)) {         out[i] <- mean(data[i:(i + windowSize - 1), ])         elements[i]<-length(i:(i + windowSize - 1))       } but this of course takes ages to
2009 Dec 10
1
Moving Averages in ggplot2
Hello all, Have some time series data stored in a data.frame, and am plotting it with ggplot2 (which is totally awesome). I have explored the documentation and mailing list archives, and I can't see any way to plot a 'smoother' that is just the K-step moving average. For example, imagine I had a data.frame called 'sleep' with 'date' as the date (from as.Date()) and
2010 Jul 17
5
Help with a problem
Hello R users, I am a researcher at the University of Michigan looking for a solution to an R problem. I have loaded my data in from a mysql database and it looks like this > data ds c1 c2 1 2010-04-03 100 0 2 2010-04-30 11141 15 3 2010-05-01 3 16 4 2010-05-02 7615 14 5 2010-05-03 6910 17 6 2010-05-04
2010 Jan 04
3
Extract vector elements until cumsum <= x
...have a vector n, and for each n[i] I want to extract n[i], n[i+1], n[i+2]..., until the cumulative sum of n[i] and subsequent elements exceeds a CheckValue, whereupon I move to the next index and repeat. I am trying to find a Vectorized approach, and have seen similar posts where filter{stat} and rollmean{zoo} were suggested, but, I haven't been able to figure a way to use them for this problem. Best wishes to all, and thanks for the help! Dgnn -- View this message in context: http://n4.nabble.com/Extract-vector-elements-until-cumsum-x-tp998023p998023.html Sent from the R help mailing list...
2011 Jun 25
1
Moving average in a data table
Hi, I'm trying to figure out common approach on calculating MA on a dataset that contains column "time". After digging around, I believe functions rollmean and rollaply should be used. However I don't quite understand the requirements for the underlying data. Should it be zoo object type? Formatted in a special way? As an example, I'm looking to get calculated avg=MA(variable) over 15 sec period on "time_sec" column: date...
2014 Jul 28
0
lattice, latticeExtra: Adding moving averages to double y plot
Hi lattice users, I would like to add 5-year moving averages to my double y-plot. I have three factors needs to be plotted with moving averages in the same plot. One of these reads off y-axis 1 and two from y-axis 2. I have tried to use the rollmean function from the zoo-packages, but I fail in insering this into lattice (I am not an experienced lattice user). I want to keep the data points in the plot. Find below dummy data and the script as well as annotations further describing my question. thank you in advance! Anna Zakrisson mydata<-...
2008 Jul 21
4
how to speed up this for loop?
Could anyone tell me a better way to achieve the output of this for loop? It seems to run quite slow. I'm sure there must be a more consise way to sum from FN to LN, excluding positive values, for each row. #sum between FN and LN, excluding positive values for(i in 1:R){ for(j in FN[i]:LN[i]){ if(Temp[i,j]<0) sum[i] <- sum[i] + sum(Temp[i,j])}} Cheers, R -- View this message in
2009 Feb 26
3
Moving Average
I am looking for some help at removing low-frequency components from a signal, through Moving Average on a sliding window. I understand thiis is a smoothing procedure that I never done in my life before .. sigh. I searched R archives and found "rollmean", "MovingAverages {TTR}", "SymmetricMA". None of the above mantioned functions seems to accept the smoothing polynomial order and the sliding window with as input parameters. Maybe I am missing something. I wonder whether there is some building blocks in R if not even a fu...
2008 Oct 24
0
"right" aligning loess
Dear R Users, Does anyone know if I can somehow "right" align the loess function, so it only uses data points up to a certain date, and not around it ? Sort of like rollmean(...align="right") in the rollmean function. Thanks, Tolga Generally, this communication is for informational purposes only and it is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction. In the...
2010 Feb 17
2
array question
Hello All: If I do have: x = (2, 4, 5, 5, 6, 4, 5, 2, 1) y = (9, 11.5, 12.5, 13, 14, 19, 20, 21, 22) I wanted to find a simple function in R which calculates the averages of X and Y for every 4 unit increase of Y. The results should look like: x = (4, 6, 3) #where (2+ 4+ 5+ 5)/ 4 = 4 and ... y = (12, 14, 20.5) #where (9+11.5+12.5+13)/ 4 = 12 and ... Thanks, Mohsen
2006 Oct 12
3
ts vs zoo
> Hello, > > I have lots of data in zoo format and would like to do some time > series analysis. (using library(zoo), library(ts) ) > > My data is usually from one year, and I try for example stl() to find > some seasonalities or trends. > > I have now accepted, that I might have to convert my series into ts() > but still I am not able to execute the comand since
2017 Sep 01
2
Area bajo la curva
Buenas noches. Quisiera saber si existe una libreria o función que me calcule el área bajo la curva de dos vectores de números. Ademas esta debe tener en cuenta si existen datos faltantes o NaN. Por ejemplo calcular el área bajo la curva del vector en el eje x: x<- c(1,2,3,4,5,6,7,8,9,10) y el vector en el eje y: y<-c(0,2,15,30,50,NaN,NaN,10,2,1) Muchas gracias. -- *Wilmer