Displaying 20 results from an estimated 3000 matches similar to: "trouble with cumsum?"
2005 Jul 13
2
Efficient testing for +ve definiteness
Dear R-users,
Is there a preferred method for testing whether a real symmetric matrix is
positive definite? [modulo machine rounding errors.]
The obvious way of computing eigenvalues via "E <- eigen(A, symmetric=T,
only.values=T)$values" and returning the result of "!any(E <= 0)" seems
less efficient than going through the LU decomposition invoked in
2003 Feb 28
3
NULL object, R programming
Dear R users,
I get the following (I think puzzling) result when doing the following:
> a <- list(3,4,5)
> a[[2]] <- NULL
> a
[[1]]
[1] 3
[[2]]
[1] 5
I would have expected the result to be:
[[1]]
[1] 3
[[2]]
NULL
[[3]]
[1] 4
as in the outcome of:
> list(3, NULL, 4)
Is this a desired effect? If so, could it be built in a 'help(NULL)' file?
If you think it is
2003 Jan 16
3
Announce: pmg -- menu driven GUI using RGtk
Hello all,
I've put together a quick and dirty menubar + dialogs + spreadsheet
GUI for R using the RGtk package. Performance is not great (OOP is a
real memory hog?), the design may be worse, but the hope is that it
will be useful in an introductory stats course while we await the
arrival of a real gui with ObveRsive and SciViews.
The package can be found at
2003 Jan 16
3
Announce: pmg -- menu driven GUI using RGtk
Hello all,
I've put together a quick and dirty menubar + dialogs + spreadsheet
GUI for R using the RGtk package. Performance is not great (OOP is a
real memory hog?), the design may be worse, but the hope is that it
will be useful in an introductory stats course while we await the
arrival of a real gui with ObveRsive and SciViews.
The package can be found at
2011 Nov 26
5
cumsum in 3d arrays
Hello!
Is it posible to apply /cumsum()/ along the 3rd dimension of 3D array?
Something like matrlab function - /cumsum (*A*,dim)/ which returns the
cumulative sum of the elements along the dimension of *A* specified by
scalar dim.
Thanks in advance
?eljka
--
View this message in context: http://r.789695.n4.nabble.com/cumsum-in-3d-arrays-tp4110470p4110470.html
Sent from the R help mailing
2009 Feb 17
2
cumsum vs. sum
I recently traced a bug of mine to the fact that cumsum(s)[length(s)]
is not always exactly equal to sum(s).
For example,
x<-1/(12:14)
sum(x) - cumsum(x)[3] => 2.8e-17
Floating-point addition is of course not exact, and in particular is
not associative, so there are various possible reasons for this.
Perhaps sum uses clever summing tricks to get more accurate results?
In some
2020 Aug 23
2
sum() vs cumsum() implicit type coercion
Hi
I noticed a small inconsistency when using sum() vs cumsum()
I have a char-based series
> tryjpy$long
[1] "0.0022" "-0.0002" "-0.0149" "-0.0023" "-0.0342" "-0.0245" "-0.0022"
[8] "0.0003" "-0.0001" "-0.0004" "-0.0036" "-0.001" "-0.0011"
2008 Jun 18
4
inverse cumsum
I've a matrix like this:
1985 1.38 1.27 1.84 2.10 0.59 3.47
1986 1.05 1.13 1.21 1.54 0.21 2.14
1987 1.33 1.21 1.77 1.44 0.27 2.85
1988 1.86 1.06 2.33 2.14 0.55 1.40
1989 2.10 0.65 2.74 2.43 1.19 1.45
1990 1.55 0.00 1.59 1.94 0.99 2.14
1991 0.92
2007 Nov 03
2
cumsum
Hi, my problem belongs to the basic ones. I want to get cumulated sum over
the matrix columns by one command (if such exists). Ordinary R's cumsum(x)
when x is:
[,1] [,2]
[1,] 1 5
[2,] 2 6
[3,] 3 7
[4,] 4 8
yields: 1 3 6 10 15 21 28 36
I want:
[,1] [,2]
[1,] 1 5
[2,] 3 11
[3,] 6 18
[4,] 10 26
Is there any command to do so??
best,
2020 Aug 25
1
sum() vs cumsum() implicit type coercion
>>>>> Tomas Kalibera
>>>>> on Tue, 25 Aug 2020 09:29:05 +0200 writes:
> On 8/23/20 5:02 PM, Rory Winston wrote:
>> Hi
>>
>> I noticed a small inconsistency when using sum() vs cumsum()
>>
>> I have a char-based series
>>
>> > tryjpy$long
>>
>> [1]
2011 May 06
1
Cumsum in Lattice Panel Function
I'm trying to create an xyplot with a "groups" argument where the y-variable
is the cumsum of the values stored in the input data frame. I almost have
it, but I can't get it to automatically adjust the y-axis scale. How do I
get the y-axis to automatically scale as it would have if the cumsum values
had been stored in the data frame?
Here is the code I have so far:
2009 Nov 21
2
how to ignore NA when using cumsum?
I would like to cumulatively sum rows in a matrix, in which each row has 1
NA value. The usual "na.rm=TRUE" does not seem to work with the command
cumsum. Is there another way to ignore the NAs or do I need to figure out a
different way to do this?
Here's an example matrix of title "proportion":
Ntrail Strail NFJD Baldy Onion Crane
[1,]
2010 Mar 23
2
Decreasing Cumsum Function?
Hi all,
I have a frequency data that looks like this.
3
2
1
5
What I want to get is the "decreasing" cumulative of this data
yielding
11
8
6
5
0
Is there any?
I am aware of cumsum(), which will yield
3
5
6
11.
But it is not what I want.
- G.V.
2024 Sep 28
1
lattice xyplot with cumsum() function inside
This code gives unexpected result.
library(data.table)
library(lattice)
set.seed(123)
mydt <- data.table(date = seq.Date(as.IDate("2024-01-01"), by = 1,
length.out = 50), xgroup = "A", x = runif(50, 0, 1))
mydt <- rbindlist(list(mydt, data.table(date = mydt$date, xgroup = "B", x = runif(50, 0, 3))))
mydt[, `:=`(xcumsum = cumsum(x)), by = .(xgroup)]
mydt[,
2009 Nov 21
1
how to ignore NA when using cumsum WHILE retaining NAs?
I would like to cumulatively sum rows in a matrix, in which each row has 1
NA value, which I do NOT want to treat as 0s. The NAs are placeholders
where there is actually no data, which is not the same as a 0. The usual
"na.rm=TRUE" does not seem to work with the command cumsum. Is there
another way to ignore the NAs or do I need to figure out a different way to
do this?
Here's an
2017 Jan 20
1
NaN behavior of cumsum
Hi!
I noticed that cumsum behaves different than the other cumulative functions wrt. NaN values:
> values <- c(1,2,NaN,1)
> for ( f in c(cumsum, cumprod, cummin, cummax)) print(f(values))
[1] 1 3 NA NA
[1] 1 2 NaN NaN
[1] 1 1 NaN NaN
[1] 1 2 NaN NaN
The reason is that cumsum (in cum.c:33) contains an explicit check for ISNAN.
Is that intentional?
IMHO, ISNA would be better
2012 Nov 22
4
Using cumsum with 'group by' ?
Hi,
First post here. Grateful for any help you can give. I have data which looks
like this:
id time x
1 12:01 5
1 12:02 14
1 12:03 6
1 12:04 3
2 12:01 98
2 12:02 23
2 12:03 1
2 12:04 4
3 12:01 5
3 12:02 65
3 12:03 23
3 12:04 23
But I want to add a column which is the cumulative sum of X, but only by id.
I've used cumsum before, but not
2009 Sep 16
2
Generalized cumsum?
Is there anything like cumsum and cumprod but which allows you to
apply an arbitrary function instead of sum and product? In other words,
I want a function cumfunc(x, f) that returns a vector, so that for all n
up to the length of x
cumapply(x,f)[n] = f(x[1:n])
This would give cumsum and cumprod as special cases when f=sum or
f=prod.
I could write such a function, but I can't see
2010 Jan 04
3
Extract vector elements until cumsum <= x
Hi All,
I 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
2009 Sep 22
3
Function similar to cumsum/cumprod
Hello, everyone
I wonder if there is in R somewhere a function similar to cumsum().
The function calculates a statistic (say mean or standard deviation)
buy adding consequtively one more data point.
So, say I have a timeseries of 100 observations.
I start by calculating mean of first 30 observations
Then I add one observation and calculate mean of 31 observations
Then I add one more observation