Displaying 1 result from an estimated 1 matches for "cond_tim".
Did you mean:
cond_time
2009 May 09
4
Generating a "conditional time" variable
...the size of my database, and considering how slow my
computer is, I don't think it's practical to use it. Also, it depends on
correct sorting of the dataframe, which might generate errors.
##
for (i in 1:nrow(test)) {
if (i == 1) { # If first id-year
cond_time <- 1
test[i, 4] <- cond_time
} else if ((test[i-1, 1]) != (test[i, 4])) { # If new id
cond_time <- 1
test[i, 4] <- cond_time
} else { # Same id as previous row
if (test[i, 3] == 0) {
test[i, 4]...