st_day<-c(1,5,10)
endday<-c(4,9,15)
d<-c(1,2,3)
data<-cbind(st_day,endday,d)
days1<-c(1:15)
dose1<-rep(c(1,2,3),each=5)
result <- cbind(days1,dose1)
Hello I have 2 coulmns with starts and end dates and corresponding dose with was a administered for certain duration. How can compute the difference and print out the duration between these two dates. I have given a sample code the expected result.
Thank you.
We can use
Map
to get the corresponding sequence of the two vectors into alist
, thencbind
theunlist
ted 'lst' and therep
licated 'd' (based on thelengths
of 'lst'