我想改变这个数据集:
id PTMIINDT PTMIINTM DGOTDIAG DGOTDGGB
1: ys00000001 20160101 614 R060 1
2: ys00000002 20160101 640 S0090 1
3: ys00000002 20160101 640 A090 2
4: ys00000003 20160101 959 R42 1
5: ys00000007 20160101 1111 S0600 1
6: ys00000008 20160101 1253 R558 1
到这个数据集:
id PTMIINDT PTMIINTM DGOTDIAG01 DGOTDGGB01 DGOTDIAG02 DGOTDGGB02
1 ys00000001 20160101 614 R060 1 NA NA
2 ys00000002 20160101 640 S0090 1 A090 2
. . . .
. . . .
. . . .
像这样。
我试图用 mutate 函数制作这个数据集。但效果不佳。我怎样才能改变这样的数据集?
ba<-n6 %>% group_by(id,PTMIINDT,PTMIINTM) %>%
mutate(DGOTDIAG01=DGOTDIAG, DGOTDIAG02=DGOTDIAG, DGOTDGGB01=DGOTDGGB,DGOTDGGB02=DGOTDGGB)
ba<-n6 %>% group_by(id,PTMIINDT,PTMIINTM) %>%
mutate(DGOTDIAG01=DGOTDIAG, DGOTDIAG02=DGOTDIAG, DGOTDGGB01=DGOTDGGB,DGOTDGGB02=DGOTDGGB)
id PTMIINDT PTMIINTM DGOTDIAG01 DGOTDGGB01 DGOTDIAG02 DGOTDGGB02
1 ys00000001 20160101 614 R060 1 NA NA
2 ys00000002 20160101 640 S0090 1 A090 2
. . . .
. . . .
. . . .