Displaying 20 results from an estimated 10000 matches similar to: "(newbie) sum for certain number of rows"
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,
2006 May 18
2
Using Apache auth to secure certain areas of Rails app
Hello! My setup is Rails 1.1 with Apache 2.x proxying the Rails stuff to
lighttpd. I know how to set up Apache to secure my entire Rails app to
require a username/password challenge. Is it possible to set up the
challenge for only parts of my application? E.g., let''s say I have a
"pub" controller whose views are accessible to anyone.
I am already implementing user
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
2008 Mar 08
1
Deleting rows satisfying a certain condition (sum of some colums>2)
I have a huge matrix and need to delete certain rows. What I need to do is:
1.In each row, calculate the sum of jth column and (J+2)th column
2. If the sum is greater than 2 then that row needs to be deleted.
I have a sample matrix and my codes here. It does remove some rows but when
it does, it skips the next row and each time it deletes a row, the dimension
changes so it gets out of bound. I
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
2
Simulation numbers from a probability table
Dear friends,
If I have a table like this, first row A B C D ... are different
levels of the variable, first column 0 1 2 4 ... are the levels of the
"numbers", the numbers inside the table are the probabilities of the
"number" occuring.
A B C D ...
0 0.2 0.3 0.1 0.05
1 0.1 0.1 0.2 0.2
2 0.02 0.2 0 0.1
4 0.3 0.01 0.01
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
2010 Jan 12
2
Calculate the percentages of the "numbers" in every column.
Dear friends,
I have a table like this, I have A B C D ... levels, the first column
you see is just the index, and there are different numbers in the
table.
A B C D ...
1 0 2 1 0
2 1 0 2 1
3 2 3 0 0
4 0 0 1 0
5 0 2 3 1
...
I want to calculate the frequencies or the percentages of the numbers
in every column.
How do I get a table like this,
2009 Dec 30
4
[PATCH 1/3] nv50: remove vtxbuf stateobject after a referenced vtxbuf is mapped
- This avoids problematic "reloc'ed while mapped" messages and
some associated corruption as well.
Signed-off-by: Maarten Maathuis <madman2003 at gmail.com>
---
src/gallium/drivers/nouveau/nouveau_screen.c | 21 +++++++++++++++++++++
src/gallium/drivers/nouveau/nouveau_screen.h | 3 +++
src/gallium/drivers/nouveau/nouveau_stateobj.h | 13 +++++++++++++
2012 Jul 08
3
How to replace a column in a data frame with another one with a different size
Hello everyone,
I have a dataframe with 1 column and I'd like to replace that column
with a moving average.
Example:
> library('zoo')
> mydat <- seq_len(10)
> mydat
[1] 1 2 3 4 5 6 7 8 9 10
> df <- data.frame("V1" = mydat)
> df
V1
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
> df[df$V1 <- rollapply(df$V1, 3, mean)]
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 =
2011 Dec 02
2
Moving column averaging
# need zoo to use rollapply()
# your data (I called df)
df <- structure(list(a = 1:2, b = 2:3, c = c(5L, 9L), d = c(9L, 6L),
e = c(1L, 5L), f = c(4, 7)), .Names = c("a", "b", "c", "d",
"e", "f"), class = "data.frame", row.names = c(NA, -2L))
# transpose and make a zoo object
df2 <- zoo(t(df))
#rollapply to get
2010 Jul 13
2
Zoo - bug ???
Hi folks,
I am confused whether the following is a bug or it is fine
Here is the explanation
a <- zoo(c(NA,1:9),1:10)
Now If I do
rollapply(a,FUN=mean,width=3,align="right")
I get
> rollapply(a,FUN=mean,width=3,align="right")
3 4 5 6 7 8 9 10
NA NA NA NA NA NA NA NA
But I shouldn't be getting NA right ? i.e for index 10 I should get
(1/3)*(9+8+7)
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 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
2011 Mar 22
6
bug resolve yet for export OCFS2 volume to NFS client ?
I found this from ocfs1.4 document:
g) NFS
OCFS2 volumes can be exported as NFS volumes. This support is limited to
NFS version 3, which translates to Linux kernel version 2.4 or later.
Users must mount the NFS volumes on the clients using the nordirplus
mount option. This disables the READDIRPLUS RPC call to workaround a bug
in NFSD, detailed in the following link:
2011 Apr 09
5
Yearly aggregates and matrices
Hi,
I need to perform calculations on subsets of a data frame:
DF = data.frame(read.table(textConnection(" A B C D E F
1 a 1995 0 4 1
2 a 1997 1 1 3
3 b 1995 3 7 0
4 b 1996 1 2 3
5 b 1997 1 2 3
6 b 1998 6 0 0
7 b 1999 3 7 0
8 c 1997 1 2 3
9 c 1998 1 2 3
10 c 1999 6 0 0
11 d 1999 3 7 0
12 e 1995 1 2 3
13 e 1998 1 2 3
14 e 1999 6
2006 Oct 03
2
maybe use voronoi.findrejectsites?
hi all members,
please, i need you help... now a i´m working with veronoi polygons in a
area with projections, but i need cut the polygons left. On other words, i
need cut the polygons in the worked area.
R help say that use the command voronoi.findrejectsites, but in this
command i need put the numbers, any way...this command not cut!! do you
can help me?
Thank you for help me!
José Bustos
2015 Mar 04
2
adaptive bandwidth
Thanks Dragos,
I assume I will be setting those parameters during initialization of
encoder right?
Question is, if connection gets too lossy, how will opus adapt to it? Can
it automatically shift bitrate down to minimize impact?
Mark from IRC suggests that the app has to be aware of the losses and
change it on the fly.
Has anybody on the list tried this?
Kelvin Chua
On Wed, Mar 4, 2015 at 5:53
2008 Jan 20
2
Efficient way for multiplying vectors with a only certain number of rows in a matrix
Dear R-users,
I am working on a problem that I am currently not able to solve efficiently.
It is about multiplying one column of a matrix with only a certain number of
rows of another matrix.
Let me illustrate my problem with an example:
n.obs = 800
n.rowsperobs = 300
n.param = 23
Designmat = matrix(rnorm(n.obs*n.rowsperobs*n.param),ncol=n.param)
Betamat =