The below code creates a new variable "hdrs1" which takes the values of HAMD17tot_M0 if visit=0, and the values of HAMD17tot_M1 if visit =1 and the values of HAMD17tot_M3 if visit=3
I start by creating a vector than contains the values of HAMD17tot_M0, then I start modiying the vector using the ifelse command: if visit=1 then replace values by those of HAMD17tot_M1, else keep as is.
```
romain1$hdrs1<-romain1$HAMD17tot_M0
romain1$hdrs1<-ifelse(romain1$visit==1,romain1$HAMD17tot_M1, romain1$hdrs1)
romain1$hdrs1<-ifelse(romain1$visit==3,romain1$HAMD17tot_M3, romain1$hdrs1)
```