search for: previous_id

Displaying 1 result from an estimated 1 matches for "previous_id".

2011 Sep 22
2
Numbering entries for each subject
...thanks in advance Toni A <- data.frame(ID=c('A','A','A','A','B','B','B', 'C','C','C','C','C')) ID 1 A 2 A 3 A 4 A 5 B 6 B 7 B 8 C 9 C 10 C 11 C 12 C A$Session_ID <- 0 previous_ID <- '' current_index <- 1 for ( i in seq(1,nrow(A)) ) { if (A$ID[i] != previous_ID) {current_index <- 1} A$Session_ID[i] <- current_index previous_ID <- A$ID[i] current_index <- current_index + 1 } ID Session_ID 1 A 1 2 A 2 3 A...