[英]calculate difference between 2 dates and print the between dates
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. 您好,我有2个附有开始和结束日期的摘要,以及在一定期间内给予的相应剂量。 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 a list
, then cbind
the unlist
ted 'lst' and the rep
licated 'd' (based on the lengths
of 'lst' 我们可以用Map
来获取两个向量的相应序列成list
,然后cbind
的unlist
特德善堂“和rep
licated“d”(基于lengths
的“善堂”
lst <- Map(`:`, st_day, endday)
out <- cbind(unlist(lst), rep(d, lengths(lst)))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.