ggplot 纵向数据,用一条线连接参与者随时间的变化

ggplot longitudinal data with a line connecting participant change over time

我有以下数据集:

structure(list(ID = c(33714L, 35377L, 38623L, 38806L, 39593L, 
39820L, 39951L, 40286L, 40556L, 40798L, 40800L, 40815L, 43762L, 
50848L, 52183L, 52461L, 52577L, 53202L, 53320L, 53873L, 54153L, 
54206L, 54581L, 55122L, 55267L, 55462L, 55612L, 55920L, 56022L, 
56307L, 56420L, 56679L, 57405L, 57445L, 57480L, 57725L, 57809L, 
58004L, 58215L, 58229L, 58503L, 59326L, 59327L, 59344L, 59361L, 
59865L, 60099L, 60100L, 60280L, 60384L, 60429L, 60493L, 60503L, 
60575L, 60603L, 60664L, 60846L, 61415L, 61656L, 61749L, 61883L, 
62081L, 62210L, 62285L, 62937L, 62983L, 63327L, 63329L, 64081L, 
64328L, 64418L, 64507L, 64596L, 65178L, 65250L, 65302L, 65478L, 
65480L, 65487L, 65572L, 65802L, 65935L, 65974L, 65975L, 65978L, 
65991L, 65995L, 66013L, 66154L, 66237L, 66245L, 66389L, 66396L, 
66460L, 66572L, 66589L, 67174L, 73230L, 73525L, 73539L, 73677L, 
73942L, 73953L, 74034L, 74113L, 74114L, 74427L, 74439L, 74607L, 
74641L, 74657L, 74794L, 74800L, 74836L, 74942L, 74952L, 74962L, 
74969L, 74977L, 74985L, 74989L, 75220L, 75229L, 75407L, 75653L, 
75732L, 75735L, 75757L, 75895L, 75898L, 76381L, 76559L, 76574L, 
76594L, 76595L, 76746L, 76751L, 76755L, 76759L, 76775L, 77088L, 
77091L, 77099L, 77134L, 77188L, 77203L, 77252L, 77304L, 77413L, 
77453L, 77528L, 77556L, 77585L, 77668L, 78262L, 79724L, 79730L, 
79850L, 79977L, 80052L, 80819L, 80901L, 80932L, 81064L, 81065L, 
81071L, 81098L, 81142L, 81175L, 81727L, 33714L, 35377L, 38623L, 
38806L, 39593L, 39820L, 39951L, 40286L, 40556L, 40798L, 40800L, 
40815L, 43762L, 50848L, 52183L, 52461L, 52577L, 53202L, 53320L, 
53873L, 54153L, 54206L, 54581L, 55122L, 55267L, 55462L, 55612L, 
55920L, 56022L, 56307L, 56420L, 56679L, 57405L, 57445L, 57480L, 
57725L, 57809L, 58004L, 58215L, 58229L, 58503L, 59326L, 59327L, 
59344L, 59361L, 59865L, 60099L, 60100L, 60280L, 60384L, 60429L, 
60493L, 60503L, 60575L, 60603L, 60664L, 60846L, 61415L, 61656L, 
61749L, 61883L, 62081L, 62210L, 62285L, 62937L, 62983L, 63327L, 
63329L, 64081L, 64328L, 64418L, 64507L, 64596L, 65178L, 65250L, 
65302L, 65478L, 65480L, 65487L, 65572L, 65802L, 65935L, 65974L, 
65975L, 65978L, 65991L, 65995L, 66013L, 66154L, 66237L, 66245L, 
66389L, 66396L, 66460L, 66572L, 66589L, 67174L, 73230L, 73525L, 
73539L, 73677L, 73942L, 73953L, 74034L, 74113L, 74114L, 74427L, 
74439L, 74607L, 74641L, 74657L, 74794L, 74800L, 74836L, 74942L, 
74952L, 74962L, 74969L, 74977L, 74985L, 74989L, 75220L, 75229L, 
75407L, 75653L, 75732L, 75735L, 75757L, 75895L, 75898L, 76381L, 
76559L, 76574L, 76594L, 76595L, 76746L, 76751L, 76755L, 76759L, 
76775L, 77088L, 77091L, 77099L, 77134L, 77188L, 77203L, 77252L, 
77304L, 77413L, 77453L, 77528L, 77556L, 77585L, 77668L, 78262L, 
79724L, 79730L, 79850L, 79977L, 80052L, 80819L, 80901L, 80932L, 
81064L, 81065L, 81071L, 81098L, 81142L, 81175L, 81727L, 33714L, 
35377L, 38623L, 38806L, 39593L, 39820L, 39951L, 40286L, 40556L, 
40798L, 40800L, 40815L, 43762L, 50848L, 52183L, 52461L, 52577L, 
53202L, 53320L, 53873L, 54153L, 54206L, 54581L, 55122L, 55267L, 
55462L, 55612L, 55920L, 56022L, 56307L, 56420L, 56679L, 57405L, 
57445L, 57480L, 57725L, 57809L, 58004L, 58215L, 58229L, 58503L, 
59326L, 59327L, 59344L, 59361L, 59865L, 60099L, 60100L, 60280L, 
60384L, 60429L, 60493L, 60503L, 60575L, 60603L, 60664L, 60846L, 
61415L, 61656L, 61749L, 61883L, 62081L, 62210L, 62285L, 62937L, 
62983L, 63327L, 63329L, 64081L, 64328L, 64418L, 64507L, 64596L, 
65178L, 65250L, 65302L, 65478L, 65480L, 65487L, 65572L, 65802L, 
65935L, 65974L, 65975L, 65978L, 65991L, 65995L, 66013L, 66154L, 
66237L, 66245L, 66389L, 66396L, 66460L, 66572L, 66589L, 67174L, 
73230L, 73525L, 73539L, 73677L, 73942L, 73953L, 74034L, 74113L, 
74114L, 74427L, 74439L, 74607L, 74641L, 74657L, 74794L, 74800L, 
74836L, 74942L, 74952L, 74962L, 74969L, 74977L, 74985L, 74989L, 
75220L, 75229L, 75407L, 75653L, 75732L, 75735L, 75757L, 75895L, 
75898L, 76381L, 76559L, 76574L, 76594L, 76595L, 76746L, 76751L, 
76755L, 76759L, 76775L, 77088L, 77091L, 77099L, 77134L, 77188L, 
77203L, 77252L, 77304L, 77413L, 77453L, 77528L, 77556L, 77585L, 
77668L, 78262L, 79724L, 79730L, 79850L, 79977L, 80052L, 80819L, 
80901L, 80932L, 81064L, 81065L, 81071L, 81098L, 81142L, 81175L, 
81727L), Age = c(15L, 15L, 42L, 62L, 66L, 57L, 42L, 65L, 9L, 
11L, 16L, 9L, 53L, 16L, 16L, 14L, 50L, 43L, 8L, 6L, 61L, 14L, 
10L, 15L, 13L, 15L, 8L, 9L, 9L, 8L, 9L, 9L, 13L, 56L, 10L, 7L, 
8L, 8L, 6L, 15L, 42L, 8L, 11L, 43L, 69L, 14L, 12L, 10L, 16L, 
12L, 10L, 6L, 13L, 66L, 11L, 12L, 13L, 10L, 65L, 13L, 14L, 12L, 
43L, 51L, 63L, 17L, 9L, 12L, 44L, 69L, 11L, 10L, 12L, 10L, 10L, 
70L, 54L, 45L, 42L, 54L, 14L, 42L, 44L, 16L, 15L, 43L, 45L, 50L, 
53L, 53L, 49L, 69L, 14L, 65L, 14L, 13L, 67L, 59L, 52L, 54L, 44L, 
62L, 69L, 10L, 63L, 57L, 12L, 62L, 9L, 53L, 54L, 66L, 49L, 63L, 
51L, 9L, 45L, 49L, 49L, 61L, 62L, 57L, 67L, 65L, 45L, 16L, 55L, 
64L, 67L, 56L, 52L, 63L, 10L, 62L, 14L, 66L, 68L, 15L, 13L, 43L, 
47L, 55L, 69L, 67L, 52L, 15L, 64L, 55L, 44L, 13L, 48L, 71L, 64L, 
13L, 50L, 61L, 70L, 57L, 51L, 46L, 57L, 69L, 46L, 8L, 11L, 46L, 
71L, 38L, 56L, 17L, 16L, 16L, 46L, 67L, 70L, 61L, 47L, 69L, 11L, 
13L, 18L, 10L, 57L, 18L, 18L, 15L, 54L, 47L, 10L, 8L, 64L, 15L, 
12L, 16L, 14L, 16L, 9L, 11L, 11L, 10L, 10L, 11L, 14L, 59L, 12L, 
8L, 9L, 9L, 8L, 16L, 44L, 9L, 13L, 45L, 71L, 16L, 13L, 12L, 18L, 
13L, 11L, 8L, 14L, 68L, 12L, 13L, 14L, 11L, 67L, 14L, 15L, 14L, 
46L, 53L, 65L, 18L, 11L, 14L, 46L, 70L, 12L, 12L, 13L, 11L, 11L, 
71L, 55L, 46L, 44L, 55L, 15L, 43L, 45L, 17L, 16L, 44L, 46L, 51L, 
55L, 54L, 50L, 70L, 15L, 66L, 15L, 14L, 68L, 60L, 53L, 55L, 46L, 
63L, 70L, 11L, 64L, 58L, 13L, 63L, 10L, 54L, 55L, 67L, 50L, 64L, 
52L, 11L, 46L, 50L, 50L, 62L, 63L, 58L, 68L, 66L, 46L, 18L, 56L, 
65L, 68L, 57L, 53L, 64L, 11L, 63L, 15L, 67L, 69L, 16L, 14L, 44L, 
48L, 56L, 70L, 68L, 53L, 17L, 65L, 56L, 45L, 14L, 49L, 73L, 65L, 
14L, 50L, 62L, 71L, 58L, 52L, 47L, 58L, 70L, 47L, 9L, 12L, 47L, 
72L, 39L, 57L, 18L, 18L, 18L, 47L, 68L, 71L, 62L, 48L, 70L, 12L, 
14L, 19L, 11L, 58L, 19L, 19L, 16L, 55L, 49L, 11L, 9L, 65L, 17L, 
13L, 18L, 16L, 18L, 11L, 12L, 12L, 11L, 11L, 12L, 16L, 60L, 13L, 
9L, 11L, 10L, 9L, 17L, 45L, 11L, 14L, 46L, 72L, 17L, 14L, 13L, 
19L, 15L, 12L, 9L, 15L, 69L, 14L, 14L, 15L, 12L, 68L, 16L, 17L, 
15L, 47L, 54L, 66L, 20L, 12L, 15L, 47L, 71L, 13L, 13L, 14L, 12L, 
12L, 72L, 56L, 47L, 45L, 56L, 16L, 44L, 46L, 19L, 18L, 44L, 47L, 
52L, 56L, 55L, 51L, 71L, 16L, 67L, 16L, 15L, 69L, 60L, 54L, 56L, 
46L, 64L, 71L, 12L, 65L, 59L, 14L, 64L, 11L, 55L, 57L, 68L, 51L, 
65L, 53L, 11L, 47L, 51L, 51L, 63L, 64L, 59L, 69L, 67L, 48L, 19L, 
57L, 66L, 69L, 59L, 54L, 65L, 12L, 64L, 16L, 68L, 70L, 17L, 15L, 
45L, 48L, 57L, 71L, 69L, 54L, 18L, 66L, 57L, 50L, 15L, 50L, 74L, 
66L, 15L, 51L, 63L, 72L, 59L, 53L, 48L, 59L, 71L, 48L, 10L, 13L, 
48L, 73L, 40L, 58L, 19L), Timepoint = c("bl", "bl", "bl", "bl", 
"bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", 
"bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", 
"bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", 
"bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", 
"bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", 
"bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", 
"bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", 
"bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", 
"bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", 
"bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", 
"bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", 
"bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", 
"bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", 
"bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", 
"bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", "bl", 
"bl", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", 
"FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", 
"FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", 
"FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", 
"FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", 
"FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", 
"FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", 
"FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", 
"FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", 
"FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", 
"FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", 
"FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", 
"FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", 
"FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", 
"FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", 
"FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", 
"FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", 
"FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", 
"FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", 
"FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", 
"FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", "FLU1", 
"FLU1", "FLU1", "FLU1", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", 
"FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", 
"FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", 
"FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", 
"FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", 
"FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", 
"FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", 
"FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", 
"FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", 
"FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", 
"FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", 
"FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", 
"FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", 
"FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", 
"FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", 
"FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", 
"FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", 
"FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", 
"FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", 
"FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", 
"FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", "FLU2", 
"FLU2", "FLU2", "FLU2", "FLU2", "FLU2"), Y= c(0.316483, 
0.3510685, 0.267147, 0.254661, 0.3249415, 0.2461125, 0.3238965, 
0.375393, 0.2516335, 0.3038465, 0.3206155, 0.2868495, 0.3346625, 
0.297433, 0.2869195, 0.3351975, 0.315691, 0.2660795, 0.3195265, 
0.3481915, 0.2785565, 0.3471645, 0.315884, 0.251254, 0.3061215, 
0.334314, 0.2758345, 0.3539715, 0.307193, 0.224277, 0.302592, 
0.327028, 0.2510545, 0.307193, 0.361899, 0.231769, 0.350601, 
0.337318, 0.302148, 0.321019, 0.335075, 0.3318655, 0.3464885, 
0.348252, 0.3281445, 0.3341985, 0.3437265, 0.28315, 0.3351165, 
0.344683, 0.328796, 0.2996415, 0.329305, 0.294367, 0.3512895, 
0.3617735, 0.320697, 0.307166, 0.31381, 0.299173, 0.332073, 0.3212095, 
0.2990235, 0.323863, 0.3450765, 0.2904305, 0.3595685, 0.3391065, 
0.3245175, 0.3418675, 0.2913055, 0.298335, 0.3394605, 0.344435, 
0.284265, 0.3228975, 0.3116815, 0.3157865, 0.31368, 0.286124, 
0.3255705, 0.343879, 0.3436655, 0.2713715, 0.3381005, 0.3385825, 
0.3190355, 0.3597505, 0.3271475, 0.3115485, 0.3276145, 0.3437875, 
0.3158815, 0.3218285, 0.326796, 0.3061665, 0.3555745, 0.3250755, 
0.321343, 0.337907, 0.3159475, 0.301024, 0.3316655, 0.3446295, 
0.3135155, 0.3220135, 0.3710685, 0.2866515, 0.300246, 0.3141975, 
0.332256, 0.3296115, 0.321672, 0.287862, 0.354463, 0.321344, 
0.304759, 0.337911, 0.3248345, 0.3188435, 0.3068095, 0.3741625, 
0.336544, 0.351038, 0.343052, 0.3070755, 0.3310035, 0.3137875, 
0.328222, 0.3308255, 0.309383, 0.3096755, 0.299197, 0.3684665, 
0.3453295, 0.3565655, 0.3318945, 0.3180955, 0.356223, 0.331051, 
0.2844205, 0.316385, 0.347013, 0.326344, 0.3122595, 0.318758, 
0.340933, 0.337239, 0.320081, 0.3142475, 0.34704, 0.2590365, 
0.31095, 0.317086, 0.342804, 0.271582, 0.2907645, 0.3033985, 
0.3154525, 0.3431455, 0.2930245, 0.321643, 0.3315875, 0.328915, 
0.317671, 0.2761495, 0.316245, 0.2994025, 0.318245, 0.321339, 
0.304061, 0.343661, 0.364479, 0.422177, 0.336406, 0.4360775, 
0.431759, 0.551526, 0.360302, 0.3366225, 0.366922, 0.4045765, 
0.438962, 0.413869, 0.47766, 0.399727, 0.4291085, 0.392142, 0.298705, 
0.384851, 0.4458605, 0.4267625, 0.5074985, 0.4166865, 0.3624645, 
0.355097, 0.371998, 0.4026565, 0.394587, 0.4266775, 0.359452, 
0.3602025, 0.3239235, 0.465567, 0.3406095, 0.379266, 0.3829545, 
0.3001825, 0.3070205, 0.337183, 0.3470225, 0.2872695, 0.2397505, 
0.384583, 0.31425, 0.3507945, 0.322995, 0.3394435, 0.3248025, 
0.465641, 0.3814155, 0.447724, 0.476956, 0.3811095, 0.393495, 
0.4225625, 0.4458295, 0.5006175, 0.573243, 0.2731625, 0.3469725, 
0.2817295, 0.355942, 0.3646175, 0.4315395, 0.3598715, 0.320289, 
0.4525705, 0.45767, 0.3783415, 0.3265225, 0.3859595, 0.399652, 
0.3192395, 0.363831, 0.255776, 0.415348, 0.3149745, 0.385126, 
0.4040365, 0.4392415, 0.437599, 0.342367, 0.33794, 0.371595, 
0.4231125, 0.369113, 0.5048805, 0.407081, 0.426632, 0.4669405, 
0.498586, 0.3120405, 0.512765, 0.324551, 0.5138265, 0.438992, 
0.4962935, 0.3793875, 0.3983455, 0.356357, 0.500609, 0.3530475, 
0.397734, 0.3654065, 0.586417, 0.397747, 0.3488145, 0.348009, 
0.4855975, 0.4796185, 0.398821, 0.23766685, 0.2879735, 0.464019, 
0.483847, 0.424666, 0.405981, 0.4565805, 0.443888, 0.373121, 
0.497016, 0.325832, 0.29513, 0.360279, 0.310338, 0.3686845, 0.5260735, 
0.418044, 0.4611725, 0.422742, 0.524288, 0.3756185, 0.5350645, 
0.359579, 0.4216595, 0.531735, 0.325213, 0.416794, 0.3086945, 
0.476911, 0.417055, 0.367398, 0.3835135, 0.3543355, 0.2774475, 
0.3838255, 0.4137145, 0.41027, 0.320498, 0.3666675, 0.3328, 0.4290855, 
0.43273, 0.4962885, 0.4780125, 0.1868879, 0.4624855, 0.387486, 
0.4414375, 0.3715215, 0.4373405, 0.3734055, 0.504994, 0.390789, 
0.32263, 0.4865625, 0.3671995, 0.304613, 0.274749, 0.407124, 
0.4525775, 0.3925285, 0.5137415, 0.3717735, 0.4723275, 0.3507395, 
0.4252795, 0.4701835, 0.360428, 0.310781, 0.3773925, 0.6055285, 
0.363959, 0.3923125, 0.3428465, 0.4076295, NA, 0.3555165, 0.3647205, 
0.3362415, 0.534173, 0.402152, 0.4024455, 0.3842045, 0.3529015, 
0.272346, 0.3459395, 0.35126, 0.20864645, 0.3229325, 0.356936, 
0.3405805, 0.5636255, 0.337367, 0.320095, 0.3906175, 0.365849, 
0.401626, 0.289955, 0.3086145, 0.3065305, 0.320703, 0.343367, 
0.34818, 0.3255665, 0.2789305, 0.3916805, 0.3944865, 0.3942745, 
0.3738695, 0.404947, 0.51239, 0.264291, 0.3859165, 0.368662, 
0.2892165, 0.422089, 0.6412535, 0.2760925, 0.321015, 0.342343, 
0.3003465, 0.292028, 0.423512, 0.3519995, 0.315446, 0.3744605, 
0.3531725, 0.3661505, 0.3296695, 0.402675, 0.338013, 0.3403915, 
0.4456495, 0.317124, 0.4084475, 0.428917, 0.3473205, 0.3872645, 
0.409326, 0.4445645, 0.40162, 0.4054015, 0.351886, 0.4580145, 
0.5862265, 0.4198715, 0.501886, 0.2876125, 0.478571, 0.50619, 
0.288397, 0.577856, 0.377296, 0.3903115, 0.4454945, 0.5611185, 
0.432694, 0.4608715, 0.3111335, 0.472336, 0.22094195, 0.3504545, 
0.448299, 0.442617, 0.3571075, 0.4083175, 0.345069, 0.4411865, 
0.4919915, 0.3915085, 0.2891742, 0.3528735, 0.399463, 0.4903135, 
0.429305, 0.3191475, 0.541327, 0.423727, 0.2318635, 0.4578195, 
0.4064885, 0.252442, 0.4064935, 0.2989955, 0.452214, 0.508416, 
0.4464025, 0.4146195, 0.393731, 0.45452, 0.328378, 0.554824, 
0.320771, 0.3326585, 0.245085, 0.38559, 0.451098, 0.2760385, 
0.4754385, 0.3392265, 0.457163, 0.3498195, 0.398216, 0.2247135, 
0.3414755, 0.3232885, 0.404982, 0.2963175, 0.3288905, 0.407173, 
0.503148, 0.3704185, 0.5039755, 0.4017825, 0.30019, 0.494287, 
0.372047, 0.394702, 0.40875, 0.3955425, 0.3578255, 0.4258825, 
0.408133, 0.315053, 0.4899055, 0.3626775, 0.4157275, 0.3290235
)), row.names = c(NA, -510L), class = c("tbl_df", "tbl", "data.frame"))

我可以使用以下方法绘制 3 个时间点的所有值:

DF %>%
  ggplot(aes(x = Age, y = Y)) +
  geom_point(aes(colour = Timepoint), alpha = .4)+
  stat_smooth(aes(group = ID),
              method = "loess", se = F) +
  #facet_grid(~Timepoint) +
  theme_classic()

但是,我正在努力将参与者与每个时间点之间的一条线联系起来,以可视化个体主题的变化。

理想情况下,我想要这样的东西: 其中每一行是个体受试者在 3 个时间点的变化

当你每组只有三个数据点时,你无法适应黄土。

要么使用简单的线性模型:

ggplot(DF, aes(x = Age, y = Y)) +
  geom_point(aes(colour = Timepoint), alpha = .4)+
  stat_smooth(aes(group = ID), method = "lm", se = F, size = .1, col = 1) +
  theme_classic()

或者只是连接点:

ggplot(DF, aes(x = Age, y = Y)) +
  geom_point(aes(colour = Timepoint), alpha = .4)+
  geom_path(aes(group = ID), size = .1, col = 1) +
  theme_classic()

我无法使用您提供的数据,因此在下面制作了一些模拟数据。

注意到我在顶行添加了 group 美学吗?这将被像 geom_line 这样的 geoms 引用,我用它来连接各个数据点。我建议使用 geom_line 而不是 stat_smooth,因为您声明的目标只是随着时间的推移连接个人数据。



ID =  c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4)
Age = c(1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4)
Y =   c(2,3,4,5,1,2,3,4,3,3,3,3,2,2,2,2)
Timepoint = c(1,1,1,1,2,2,2,2,3,3,3,3,1,1,1,1)

DF <- data.frame(ID, Age, Y) %>% 
  mutate(ID = factor(ID),
         Age = factor(Age),
         Timepoint = factor(Timepoint))

DF %>%
  ggplot(aes(x = Age, y = Y, group = ID)) +
  geom_point(aes(colour = Timepoint), alpha = .75)+
  geom_line(size = .1) +
  #facet_grid(~Timepoint) +
  theme_classic()