[R & SAS] 그룹핑 변수에 따라 순번(시퀀스) 부여

 In R Lang

그룹별로 시퀀스 할당하기

1. SAS

proc sort

by id_var tme_var;


if first.id_var then seq = 0;

seq + 1;

2. R

df$seq <- with(df, ave(id_var, time_var, FUN=seq_along))

출처: http://raccoonjin.tistory.com/82?category=731290 [지식노동자의 노트]

Recommended Posts

Leave a Comment

Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.

Not readable? Change text. captcha txt