similar to: Zoo rolling window with increasing window size

Displaying 20 results from an estimated 7000 matches similar to: "Zoo rolling window with increasing window size"

2017 Aug 10
3
Zoo rolling window with increasing window size
Hi Joshua, thanks for your prompt reply. However as I said, sum() function I used here just for demonstrating the problem, I have other custom function to implement, not necessarily sum() I am looking for a generic solution for above problem. Any better idea? Thanks, On Fri, Aug 11, 2017 at 12:04 AM, Joshua Ulrich <josh.m.ulrich at gmail.com> wrote: > Use a `width` of integer index
2017 Aug 10
0
Zoo rolling window with increasing window size
Replace "sum" with your custom function's name. I don't see any reason why that wouldn't work, and the problem with my solution is not clear in your response. r <- rollapplyr(x, seq_along(x), yourCustomFunctionGoesHere) On Thu, Aug 10, 2017 at 1:39 PM, Christofer Bogaso <bogaso.christofer at gmail.com> wrote: > Hi Joshua, thanks for your prompt reply. However
2017 Aug 10
0
Zoo rolling window with increasing window size
Use a `width` of integer index locations. And you likely want = "right" (or rollapplyr(), as I used). R> set.seed(21) R> x <- rnorm(10) R> rs <- rollapplyr(x, seq_along(x), sum) R> cs <- cumsum(x) R> identical(rs, cs) [1] TRUE On Thu, Aug 10, 2017 at 1:28 PM, Christofer Bogaso <bogaso.christofer at gmail.com> wrote: > Hi again, > > I am
2018 Apr 24
2
Rolling window difference for zoo time series
Hi, I have a 'zoo' time series as below : Zoo_TS = zoo(5:1, as.Date(Sys.time())+0:4) Now I want to calculate First order difference of order 1, rolling window basis i.e. (Zoo_TS[2] - Zoo_TS[1] ) / Zoo_TS[1] (Zoo_TS[3] - Zoo_TS[2] ) / Zoo_TS[2] ..... Is there any direct function available to achieve this? Thanks,
2018 Apr 24
0
Rolling window difference for zoo time series
Zoo_TS/lag(Zoo_TS) - 1 On Tue, Apr 24, 2018 at 9:29 PM, Christofer Bogaso < bogaso.christofer at gmail.com> wrote: > Hi, > > I have a 'zoo' time series as below : > > Zoo_TS = zoo(5:1, as.Date(Sys.time())+0:4) > > Now I want to calculate First order difference of order 1, rolling > window basis i.e. > > (Zoo_TS[2] - Zoo_TS[1] ) / Zoo_TS[1] >
2011 Jan 21
3
How to look into the asterisked function?
Hi friends, there is methods() function to see the all available methods for a particular function, for example: > head(methods("print")) [1] "print.acf" "print.anova" "print.aov" "print.aovlist" "print.ar" "print.Arima" In this list, there are some functions which are asterisked like print.acf().
2009 Jul 01
1
A problem on zoo object
I have a zoo object on daily data for 10 years. Now I want to create a list, wherein each member of that list is the monthly observations. For example, 1st member of list contains daily observation of 1st month, 2nd member contains daily observation of 2nd month etc. Then for a particular month, I want to divide all observations into 3 parts (arbitrary) and then want to calculate some statistics
2012 Apr 05
1
is parallel computing possible for 'rollapplyr' job?
  Hi,   The code below does exactly what I want in sequential mode. But, it is slow and I want to run it in parallel mode. I examined some windows version packages (parallel, snow, snowfall,..) but could not solve my specific problem. As far as I understood, either I have to write a new function like sfRollapplyr or I have to change my code in a way that it utilizes lapply, or sapply instead of
2011 Apr 06
2
A zoo related question
Dear all, please consider my following workbook: library(zoo) lis1 <- vector('list', length = 2) lis2 <- vector('list', length = 2) lis1[[1]] <- zooreg(rnorm(20), start = as.Date("2010-01-01"), frequency = 1) lis1[[2]] <- zooreg(rnorm(20), start = as.yearmon("2010-01-01"), frequency = 12) lis2[[1]] <- matrix(1:40, 20) lis2[[2]] <-
2018 Mar 04
3
Change Function based on ifelse() condtion
Below is my full implementation (tried to make it simple as for demonstration) Lapply_me = function(X = X, FUN = FUN, Apply_MC = FALSE, ...) { if (Apply_MC) { return(mclapply(X, FUN, ...)) } else { if (any(names(list(...)) == 'mc.cores')) { myList = list(...)[!names(list(...)) %in% 'mc.cores'] } return(lapply(X, FUN, myList)) } } Lapply_me(as.list(1:4), function(xx) { if (xx ==
2010 Jul 10
7
Need help on date calculation
Hi all, please see my code: > library(zoo) > a <- as.yearmon("March-2010", "%B-%Y") > b <- as.yearmon("May-2010", "%B-%Y") > > nn <- (b-a)*12 # number of months in between them > nn [1] 2 > as.integer(nn) [1] 1 What is the correct way to find the number of months between "a" and "b", still
2018 Mar 04
0
Change Function based on ifelse() condtion
The reason that it works for Apply_MC=TRUE is that in that case you call mclapply(X,FUN,...) and the mclapply() function strips off the mc.cores argument from the "..." list before calling FUN, so FUN is being called with zero arguments, exactly as it is declared. A quick workaround is to change the line Lapply_me(as.list(1:4), function(xx) { to Lapply_me(as.list(1:4),
2018 Mar 04
2
Change Function based on ifelse() condtion
My modified function looks below : Lapply_me = function(X = X, FUN = FUN, Apply_MC = FALSE, ...) { if (Apply_MC) { return(mclapply(X, FUN, ...)) } else { if (any(names(list(...)) == 'mc.cores')) { myList = list(...)[!names(list(...)) %in% 'mc.cores'] } return(lapply(X, FUN, myList)) } } Here, I am not passing ... anymore rather passing myList On Sun, Mar 4, 2018 at 10:37 PM,
2018 Mar 04
2
Change Function based on ifelse() condtion
@Eric - with this approach I am getting below error : Error in FUN(X[[i]], ...) : unused argument (list()) On Sun, Mar 4, 2018 at 10:18 PM, Eric Berger <ericjberger at gmail.com> wrote: > Hi Christofer, > You cannot assign to list(...). You can do the following > > myList <- list(...)[!names(list(...)) %in% 'mc.cores'] > > HTH, > Eric > > On Sun, Mar
2012 Dec 14
5
A question on list and lapply
Dear all, let say I have following list: Dat <- vector("list", length = 26) names(Dat) <- LETTERS My_Function <- function(x) return(rnorm(5)) Dat1 <- lapply(Dat, My_Function) However I want to apply my function 'My_Function' for all elements of 'Dat' except the elements having 'names(Dat) == "P"'. Here I have specified the name
2017 Aug 02
4
Extracting numeric part from a string
Hi again, I am struggling to extract the number part from below string : "\"cm_ffm\":\"563.77\"" Basically, I need to extract 563.77 from above. The underlying number can be a whole number, and there could be comma separator as well. So far I tried below : > library(stringr) > str_extract("\"cm_ffm\":\"563.77\"",
2012 Mar 16
4
How to start R in maximized size???
Dear all, when I start R, I want that the console window should be in the Maximized size automatically. Can somebody help me how to achieve that? Thanks and regards,
2009 Nov 27
2
How to compute Rolling analysis of Standard Deviation using ZOO package?
Hello: I want to get a rolling estimation of the stdev of my data. Searching the document, I found the function "rollapply" in the zoo package. For example, my series is "c", and i want get a period of 10 days, so i write the command below: roll.sd = rollapply( c, 10, sd, na.pad = TRUE, align = 'right' ) but there is an error in it ,and the computing cannot be
2013 Mar 28
4
How to replace '$' sign?
Hello again, I want to remove "$" sign and replace with nothing in my text. Therefore I used following code: > gsub("$|,", "", "$232,685.35436") [1] "$232685.35436" However I could not remove '$' sign. Can somebody help me why is it so? Thanks and regards
2018 Mar 04
0
Change Function based on ifelse() condtion
That's fine. The issue is how you called Lapply_me(). What did you pass as the argument to FUN? And if you did not pass anything that how is FUN declared? You have not shown that in your email. On Sun, Mar 4, 2018 at 7:11 PM, Christofer Bogaso < bogaso.christofer at gmail.com> wrote: > My modified function looks below : > > Lapply_me = function(X = X, FUN = FUN, Apply_MC =