similar to: partial cumsum

Displaying 20 results from an estimated 10000 matches similar to: "partial cumsum"

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
2010 May 26
5
counts of a vector
Hi, I need help to find an efficient way to transform a vector like: a<-c(1,1,0,1,0,0,0,1,1,1,1,0,1,0,1,1) in a vector that counts only di 1 elements, like: b<-c(1,2,0,1,0,0,0,1,2,3,4,0,1,0,1,2) Thank you! -- View this message in context: http://r.789695.n4.nabble.com/counts-of-a-vector-tp2232047p2232047.html Sent from the R help mailing list archive at Nabble.com.
2010 Nov 25
6
help: program efficiency
hey guys, I am working on a function to make a duplicated value unique. For example, the original vector would be like : a = c(2,1,1,3,3,3,4) I'll like to transform it into: a.nodup = 2, 1.01, 1.02, 3.01, 3.02, 3.03, 4 basically, find the duplicates and assign a unique value by adding a small amount and keep it in order. I come up with the following codes, but it runs slow if t is large. Is
2013 Oct 11
3
Create sequential vector for values in another column
Hello all - I have an example column in a dataFrame id.name 123.45 123.45 123.45 123.45 234.56 234.56 234.56 234.56 234.56 234.56 234.56 345.67 345.67 345.67 456.78 456.78 456.78 456.78 456.78 456.78 456.78 456.78 456.78 ... [truncated] And I'd like to create a second vector of sequential values (i.e., 1:N) for each unique id.name value. In other words, I need id.name x 123.45 1 123.45
2011 Nov 02
3
how to count number of occurrences
Dear R users, I have this data frame, y samp 8 0.03060419 X 18 0.06120838 Y 10 0.23588374 X 3 0.32809965 X 1 0.36007100 X 7 0.36730571 X 20 0.47176748 Y 13 0.65619929 Y 11 0.72014201 Y 17 0.73461142 Y 6 0.76221313 X 2 0.77005691 X 4 0.92477243 X 9 0.93837591 X 5 0.98883581 X 16 1.52442626 Y 12 1.54011381 Y 14 1.84954487 Y
2012 Jun 08
2
help with rle function on paired data
Dear R Community - I hope you might be able to provide some guidance regarding the use of the rle function. I have a set of time-series data where a measured value is recorded every 30 seconds after the start of an experiment. Many of the measured values repeat and I am interested only in the values when there is a change. If I turn the measured values into a vector, the rle function works
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 Dec 07
1
Subset of time observations where timediff > 60 secs
Dear list members I have a rather large vector (part of a data frame) giving the time (date + time, POSIXct) of observations. The times are irregular (with both small and large jumps) but increasing, and there are several millions of them. I now wish to reduce my data set, so that I only have observations which are at least (for example) 60 seconds apart. Basically, I need (all) the indices
2010 Jan 27
3
Function for describing segements in sequential data
Dear R-users, Say that I have a sequence of zeroes and ones: x <- c(1,1,1,0,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,0) The sequences of ones represent segments and I want to report the starting and endpoints of these segments. For example, in 'x', the first segment starts at location 1 and ends at 3, and the second segment starts at location 8 and ends at location 10. Is there an efficient
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 14
4
local sequence function
hey, I can not find a function for the following problem, hopefully you can help me. I have a vactor like this one v = c(NA,NA,TRUE,TRUE,NA,TRUE,NA,TRUE,TRUE,TRUE) and I would like to the TRUE values by the their "local sequence number". This means, the result should look thike this: c(NA,NA,1,2,NA,1,NA,1,2,3) Of course I could solve the problems using a loop, but this would be
2012 May 23
2
Using NA as a break point for indicator variable?
Hi all, I am working with a spatial data set for which I am only interested in high concentration values ("leaks"). The low values (< 90th percentile) have already been turned into NA's, leaving me with a matrix like this: < CH4_leak lon lat CH4 1 -71.11954 42.35068 2.595834 2 -71.11954 42.35068 2.595688 3 NA NA NA 4 NA
2009 Mar 10
4
puzzled by math on date-time objects
Hi, I don't understand the following. When I create a small artificial set of date information in class POSIXct, I can calculate the mean and the median: a = as.POSIXct(Sys.time()) a = a + 60*0:10; a [1] "2009-03-10 11:30:16 EDT" "2009-03-10 11:31:16 EDT" "2009-03-10 11:32:16 EDT" [4] "2009-03-10 11:33:16 EDT" "2009-03-10 11:34:16
2009 Dec 10
3
How to figure out which the version of split is used?
There are a number of functions that are dispatched to from split(). > methods('split') [1] split.data.frame split.Date split.default split.POSIXct Is there a way to figure out which of these variants is actually dispatched to when I call split? I know that if the argument is of the type data.frame, split.data.frame will be called? Is it the case that if the argument is not
2013 Jan 15
5
Code to fetch summary info from vector
Hi all, Thanks in advance for any help. I have a vector "b": b=c(1,1,1,2,3,4,3,2,1,1,1,1,1,2,3,4,5,4,3.5,3,2,1,1,1) Imagine b is river flow throughout time. I would like some code that will generate the following information: number of individual 'periods' where b>1 (= 2 in this case) period 1 length = 5, max = 4 period 2 length = 8, max = 5 I can't figure anything
2020 Aug 26
1
NAs and rle
Hi All, A twitter user, Mike fc (@coolbutuseless) mentioned today that he was surprised that repeated NAs weren't treated as a run by the rle function. Now I know why they are not. NAs represent values which could be the same or different from eachother if they were known, so from a purely conceptual standpoint there is no way to tell whether they are the same and thus constitute a run or
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
2020 Feb 19
2
How to index the occasions in a vector repeatedly under condition 1? if not, it will give a new index.
Dear all, Could you please help me how to get the output as I described in the following example? x<-c(543, 543, 543, 543, 551 , 551 ,1128 ,1197, 1197) diff<-x-lag(x) diff [1] NA 0 0 0 8 0 577 69 0 How to index the occasions in x repeatedly if the diff<15? if diff>=15, it will give a new index. I want the output be like y. y<-c(1,1,1,1,1,1,2,3,3) Thank you so
2020 Feb 19
2
How to index the occasions in a vector repeatedly under condition 1? if not, it will give a new index.
Dear all, Could you please help me how to get the output as I described in the following example? x<-c(543, 543, 543, 543, 551 , 551 ,1128 ,1197, 1197) diff<-x-lag(x) diff [1] NA 0 0 0 8 0 577 69 0 How to index the occasions in x repeatedly if the diff<15? if diff>=15, it will give a new index. I want the output be like y. y<-c(1,1,1,1,1,1,2,3,3) Thank you so
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,]