麻烦请帮我看一下,数据是随访数据,我想新生成一个时间变量,表示末次随访时间。Freq表示随访次数,报告日期n表示第几次随访的时间。以下是我写的程序,总是出错,是不是因为赋值不是一个固定值的原因?请教大家,应该怎么写这个命令?多谢啦!
temp$time<- within(temp,{
time<-as.POSIXct(报告日期)
time[Freq==2]<-as.POSIXct(报告日期2)
time[Freq==3]<-as.POSIXct(报告日期3)
time[Freq==4]<-as.POSIXct(报告日期4)
time[Freq==5]<-as.POSIXct(报告日期5)
time[Freq==6]<-as.POSIXct(报告日期6)
time[Freq==7]<-as.POSIXct(报告日期7)
})
结果出错信息:
Warning messages:
1: In NextMethod(.Generic) :
number of items to replace is not a multiple of replacement length
2: In NextMethod(.Generic) :
number of items to replace is not a multiple of replacement length
3: In NextMethod(.Generic) :
number of items to replace is not a multiple of replacement length
4: In NextMethod(.Generic) :
number of items to replace is not a multiple of replacement length
5: In NextMethod(.Generic) :
number of items to replace is not a multiple of replacement length
--
FROM 210.75.207.*