Hello! I want to know if it's possible to do something like this :
for (i in 1:6){
commun$diffdidi+1<-round(time_length(interval(commun$final.date_testDi,commun$final.date_testDi+1),"years"),2)
}
instead of that kind of code :
commun$diffd1d2<-round(time_length(interval(commun$final.date_testD1,commun$final.date_testD2),"years"),2)
commun$diffd2d3<-round(time_length(interval(commun$final.date_testD2,commun$final.date_testD3),"years"),2)
commun$diffd3d4<-round(time_length(interval(commun$final.date_testD3,commun$final.date_testD4),"years"),2)
commun$diffd4d5<-round(time_length(interval(commun$final.date_testD4,commun$final.date_testD5),"years"),2)
commun$diffd5d6<-round(time_length(interval(commun$final.date_testD5,commun$final.date_testD6),"years"),2)
commun$diffd6d7<-round(time_length(interval(commun$final.date_testD6,commun$final.date_testD7),"years"),2)
Indeed, in my code I have a lot of repition like this and it's not the most readable code.
Thank you for your time!