similar to: replace id by running number

Displaying 20 results from an estimated 6000 matches similar to: "replace id by running number"

2009 Nov 11
2
partial cumsum
Hello, I am searching for a function to calculate "partial" cumsums. For example it should calculate the cumulative sums until a NA appears, and restart the cumsum calculation after the NA. this: x <- c(1, 2, 3, NA, 5, 6, 7, 8, 9, 10) should become this: 1 3 6 NA 5 11 18 26 35 45 any ideas? thank you and best regards, stefan
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
2003 Nov 14
2
bad performance of a function
Dear all I need to find a length of true sequences in logical vector (see example 1). I found a possible solution which is good but if I use it on a larger data set I experience a substantial decrease in performance (example 2). Example 1 set.seed(111) x <- sample(c(T,F),50, replace=T) system.time(cetnost <- as.numeric(table(which(x)-cumsum(x[which(x)])))) [1] 0.00 0.00 0.03 NA NA
2005 May 24
3
obtaining first and last record for rows with same identifier
I have a dataframe that contains fields such as patid, labdate, labvalue. The same patid may show up in multiple rows because of lab measurements on multiple days. Is there a simple way to obtain just the first and last record for each patient, or do I need to write some code that performs that. Thanks, Steven
2010 May 26
3
Peak Over Threshold values
Dear List I hope you can help me: I?ve got a dataframe (df) within which I am looking for Peak Over Threshold values as well as the length of the events. An event starts when walevel equals 5.8 and it should end when walevel equals the lower threshold value (5.35). I tried ?clusters (?)? from ?evd package?, and varied r (see example) but it did not work for all events (again
2007 Dec 04
3
Inserting a subsequence between values of a vector
Hallo, suppose I have a vector: x <- c(1,1,1,2,2,3,3,3,3,3,4) How can I generate a vector/sequence in which a fixed number of zeroes (say 3) is inserted between the consecutive values, so I get 1,1,1,0,0,0,2,2,0,0,0,3,3,3,3,3,0,0,0,4 thanks a lot, Serguei [[alternative HTML version deleted]]
2006 Mar 25
2
problem with diff
dear R users I am having a problem with the output of diff for a numeric vector which has the values (2,4,6,7), one expects to get 2 2 1 but I am getting 4 6 7, here is the setup. info <- with(rle(x), data.frame(value = values, start = cumsum(lengths)-lengths+1, end = cumsum(lengths) )[lengths > 1,] ); > x <-
2013 Jul 22
4
How to split two levels several times?
Hi, I have a small problem with the function split() and would appreciate your help. I have a table called ?XXX? with 2 columns and 49 rows. The 49 rows belong to 8 different levels (electrode1, ...,electrode8). I want to split the table always at the row where ?electrode1? starts again so that I can export 7 individual dataframes (numbered ?dataframe1? to ?dataframe7?) which contain always
2009 Jan 24
1
fonction PLATEAU???
Hello, I am working on extracting data from sound recording (fee bee song of the black-capped chickadee). I obtained a two column matrix with x=time(s) and y=frequency(khz). The part of the recording that is interesting me is when the frequency is stable. Does somebody ever used a fonction that extract only constant data among a huge list of data (sample= 180000)? Thanks Thibault Grava
2011 Feb 13
3
String manipulation
Please consider following string: MyString <- "ABCFR34564IJVEOJC3434" Here you see that, there are 4 groups in above string. 1st and 3rd groups are for english letters and 2nd and 4th for numeric. Given a string, how can I separate out those 4 groups? Thanks for your time [[alternative HTML version deleted]]
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.
2005 Nov 29
2
qcc
violating.runs I read from the news cran.r-project.org/doc/Rnews/Rnews_2004-1.pdf that the criteria for the violating is 5 but 1)I cannot find "5" in the code of the function. Where is the "5" ? 2)What is the easiest way to change it ? 3)Is there any more criterias made somewhere ? Yours sincerelly, Tommi Viitanen
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
2006 Mar 23
1
subsets of vector
dear R users I have been trying a lot to get this task accomplished but need your help. input: x <- c(3,3,4,4,4,4,5,7,7,0,1,1,2,2,2) desired output 3 1 2 4 3 6 7 8 9 ... which means, 3 is repeated at index 1:2 4 is repeated at index 3:6 ... my effort has not been that good. a <- !c(NA,diff(x)); b <- which(a==1); a[b-1]=1; cbind(x,a); or sp <-
2005 Jan 27
5
Finding "runs" of TRUE in binary vector
I have a binary vector and I want to find all "regions" of that vector that are runs of TRUE (or FALSE). > a <- rnorm(10) > b <- a<0.5 > b [1] TRUE TRUE TRUE FALSE TRUE FALSE TRUE TRUE TRUE TRUE My function would return something like a list: region[[1]] 1,3 region[[2]] 5,5 region[[3]] 7,10 Any ideas besides looping and setting start and ends directly?
2011 Jan 28
2
(no subject)
Hello, I have a data set with each column containing data like this: row column1 1 1.2 2 NA 3 NA 4 3 5 5 6 NA 7 1.5 8 NA 9 NA 10 NA 11 3 12 NA 13 3 14 NA 15 NA 16 NA 17 NA 18 3 19 1.2 20 NA >From this I would like to extract the sequence containing at least three rows of 3 in a row (exlcuding NAs). I would also like to have the row numbers showing the place of the last
2008 Apr 12
4
HOW TO AVOID LOOPS
> Looking for a simple, effective a minimum execution time solution. > > For a vector as: > > c(0,0,1,0,1,1,1,0,0,1,1,0,1,0,1,1,1,1,1,1) > To transform it to the following vector without using any loops: > (0,0,1,0,1,2,3,0,0,1,2,0,1,0,1,2,3,4,5,6) > Appreciate any suggetions. [[alternative HTML version deleted]]
2007 Jun 19
4
How do I avoid a loop?
Hi, I start with an array of booleans: x <- c( TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE ); I want to define an y <- f(x) such that: y <- c( 1, 2, 3, 0, 0, 1, 2, 0, 1 ); In other words, do a cumsum when I see a TRUE, but reset to 0 if I see a FALSE. I know I can do this with a very slow and ugly loop or maybe use apply, but I was hoping there are some R experts out
2006 Jul 17
6
Nested functions
Hi there, I'm having myself a hard time writing an algorithm for finding patterns within a given melody. In a vector I'd like to find ALL sequences that occur at least twice, without having to check all possible patterns via pattern matching. I finally found a solution in a style that I'm used from C, i.e. calling one function from within another. GNU R doesn't seem to like that,
2002 May 20
1
how does one apply Western Electric / AT&T rules to R plots?
I have searched for info on how to apply the Western Electric rules for process control, to data and plots I have in R, but I have not been able to learn how. Any help would be greatly appreciated. Thank you, sjcrauhut at agere.com 05/20/02 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read