Displaying 20 results from an estimated 80 matches similar to: "rollapply on zoo object"
2008 Jul 31
1
rollapply() to portions of a matrix
Hi everyone,
I have a rollapply statement that applies a function, in steps, over a data
matrix as follows:
#Code start
testm<-rollapply(mat, 100, by=100, min, na.rm=F)
#Code end
This moves down matrix 'mat' and calculates the minimum value over a 100 row
range, every 100 rows (i.e. no overlaps). NAs are not removed.
I want to modify this statement somehow so that the rollapply()
2009 Jun 19
1
function rollapply
Hi,
I faced with problem when start using function - rollapply(returns, 3 ,
mean)
Error in UseMethod("rollapply") :
No suitable Method for "rollaply"
How can I fix the problem? Thank you for help.
--
Best regards,
Andy Fetsun
[[alternative HTML version deleted]]
2009 Jul 07
1
Error in Rolling window of function - rollapply
Dear Colleagues,
I have faced with the problem that function rollaply with rolling window for
calculation of volatility doesn't give the all results of calculations.
I have run the rolling window for calculation in Excel and obtained that the
number of outputs for Excel is 36 and for R is 18. The total number of
observations is 37. In the attachment you can find pdf of the Excel and
Excel
2012 Oct 26
1
rollapply() by time, not entries (width)
Hi all-
Thank you for reading my post. Please bear in mind that I'm very much a
newbie with R! My question is this:
I'm trying to use rollapply() on an irregular time series so I can't simply
use the width parameter (I don't think). Rather than last 5 entries, I'd
like to rollapply on last 6 months (for example). What would be the proper
course of action for this?
Thanks!
2010 Apr 09
3
"fill in" values between rollapply
Hi,
Sorry ahead of time for not including data with this question.
Using rollapply to calculate mean values for 5 day blocks, I'd use this:
Roll5mean <- rollapply(data, 5, mean, by=5, align = c("left"))
My question is, can someone tell me how to fill in the days between each of
these means with the previously calculated mean? If this doesn't make
sense, I will clarify and
2011 Aug 12
2
rollapply.zoo() with na.rm=TRUE
Hi.
I'm comparing output from rollapply.zoo, as produced by two versions
of R and package zoo. I'm illustrating with an example from a R-help
posting 'Zoo - bug ???' dated 2010-07-13.
My question is not about the first version, or the questions raised in
that posting, because the behaviour is as documented. I'm puzzled as
to why na.rm no longer is passed to mean, i.e. why
2009 Mar 23
1
performance: zoo's rollapply() vs inline
zoo's rollapply() function appears to be extremely useful for plugging in a
function on-the-fly to run over a window. With inline, there is a lot more
coding and room for error, and the code is less portable because the user
has to have R compiling set up or it won't work.
However, rollapply() seems to be really slow. Several orders of magnitude
slower than inline, in fact. I don't
2010 Jan 13
1
Rollapply
Hi
I would like to understand how to extend the function (FUN) I am using in
rollapply below.
######################################
With the following simplified data, test1 yields parameters for a rolling
regression
data = data.frame(Xvar=c(70.67,70.54,69.87,69.51,70.69,72.66,72.65,73.36),
Yvar =c(78.01,77.07,77.35,76.72,77.49,78.70,77.78,79.58))
data.z = zoo(d)
test1 =
2012 Jul 10
1
Help with vectors and rollapply
Hello
I have a vector a =(-2,0,0,0,1,0,0,3,0,0,-4)
I want to replace all zeros into previous non-zero state. So for instance the above vector should be converted into:
a= (-2,-2,-2,-2,1,1,1,3,3,3,-4)
I tried many things and finally concluded that probably(?) rollapply may be the best way?
I tried
f= function(x){
ifelse(x==0,Lag(x),x)
}
And then, rollappy(a,1,f) and that
2012 Jan 24
1
problems with rollapply {zoo}
Here is a relatively simple script (with comments as to the logic
interspersed):
# Some of these libraries are probably not needed here, but leaving them in
place harms nothing:
library(tseries)
library(xts)
library(quantmod)
library(fGarch)
library(fTrading)
library(ggplot2)
# Set the working directory, where the data file is located, and read the
raw data
2012 Oct 16
2
sliding window analysis with rollapply
Dear List members
I want to do the sliding window analysis of some specific values. Here is my code:
require(zoo)
dat <- read.table("chr1.txt", header = TRUE, sep="\t")
dat2 <- cbind(dat[1,3]) #The first column is also important. It represents the position of the site on the chromosome.
TS <- zoo(c(dat2))
a <- rollapply(TS, width=1000000, by=200000, FUN=mean,
2011 Apr 03
1
zoo:rollapply by multiple grouping factors
# Hi there,
# I am trying to apply a function over a moving-window for a large
number of multivariate time-series that are grouped in a nested set of
factors. I have spent a few days searching for solutions with no luck,
so any suggestions are much appreciated.
# The data I have are for the abundance dynamics of multiple species
observed in multiple fixed plots at multiple sites. (I total I
2013 Jun 27
3
using "rollapply" to calculate a moving sum or running sum?
#using "rollapply" to calculate a moving sum or running sum?
#I am tryign to use rollapply to calcualte a moving sum? #I tried
rollapply and get the error message
#"Error in seq.default(start.at, NROW(data), by = by) :
# wrong sign in 'by' argument"
#example:
mymatrix <- ( matrix(data=1:100, nrow=5, ncol=20) )
mymatrix_cumsum <- ( matrix(data=NA, nrow=5,
2011 Nov 19
3
persp() problem
Hi, and thanks in advance for any assistance,
I'm new to R and to this mailing list, and am having trouble with the *
persp()* function. I've got a matrix (z) of values for various combinations
of x and y, each of which is a set of (0, 5, 10, 15, 20). But when I try *
persp(x,y,z)*, I get an "*invalid z argument*" error, and when I try simply
*persp(z)*, R returns an
2010 May 09
1
Plot polygon in 3D with rgl
Dear R-helpers, an rgl-ers in particular,
what is the easiest way to plot a section of a plane in 3D, that is
given by the xyz coordinates of the outline?
Suppose I have a polygon - which I know for sure is a set of
coordinates on the same plane. One method I found is to use surf.tri
from the geometry package, and then plot the triangles with
rgl.triangles. This method is not perfect though,
2011 Jul 21
1
Select Random Rows from a dataframe
Hi all,
I have a dataframe of behavioral observations from 360 fish, each with 241 observation points(rows), which looks like this:
> head(d)
fish treatment tank trial video tid pid ang.chg abs.ac t len vel d2p x y
1 1 3 1 1 1 1 1 NA NA 0.0 0.000 NA NA 5.169 9.617
2
2012 Nov 28
7
zeros in double matrix rather than character matrix
Hi, how are you?
I have 1000 total columns with 100 rows and I have shown 4 columns of 100
rows below. I want the zeros to be read in as numerical or integer values
rather than a character. Right now I have a 100x0 character matrix rather
than a 100x1000 double matrix.
What do I need to do to read in a .csv spreadsheet with counting the zeros
as a numerical or integer value?
Thank-you.
Irucka
2012 Nov 28
1
how to keep all zeros in 1st row (not NA)
Hi, let me correct my previous post ("zeros in double matrix rather than
character matrix").
I have included entries from the .csv file that has 4 columns of 1000
columns and 101 rows. The first column with the "Time (day)" will not be
removed, but the row headers are the numbers 1 to 1000 and they will remain
in the matrix.
In the previous post I mentioned that R makes the
2006 Aug 24
1
how to constrast with factorial experiment
Hello, R users,
I have two factors (treat, section) anova design experiment where
there are 3 replicates. The objective of the experiment is to test if
there is significant difference of yield between top (section 9 to 11)
and bottom (section 9 to 11) of the fruit tree under treatment. I
found that there are interaction between two factors. I wonder if I
can contrast means from levels of
2017 Sep 07
0
investigate & troubleshoot speed bottleneck(s) - how?
hi guys/gals
I realize that this question must have been asked before, I
sroogled and found some posts on the web on how to
tweak/tune gluster, however..
What I hope is that some experts and/or devel could write a
bit more, maybe compose a doc on - How to investigate and
trouble gluster's speed-performance bottleneck.
Why I think such a thorough guide would be important? Well..
I guess