英文:
Remove vertical lines in ggplot
问题
I am using some longitudinal data to make a line plot with ggplot2
. The goal is to plot the data for each individual (Name
) across time (Age
). However, I don't know why there are vertical lines shown in the plot:
ggplot(sum_data, aes(x=Age, y=Turns, group=Name)) +
geom_line()
How do I remove those vertical lines? Thanks for any help!
Here is the data:
dput(sum_data)
structure(list(Age = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
<details>
<summary>英文:</summary>
I am using some longitudinal data to make a line plot with `ggplot2`. The goal is to plot the data for each individual (`Name`) across time (`Age`). However, I don't know why there are vertical lines shown in the plot:
ggplot(sum_data, aes(x=Age,y=Turns,group=Name))+
geom_line()
[![1]][1]
How do I remove those vertical lines? Thanks for any help!
Here is the data:
dput(sum_data)
structure(list(Age = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7), Speaker = c("CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI", "CHI",
"CHI", "CHI", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT", "MOT",
"MOT", "MOT", "MOT", "MOT"), Name = structure(c(1L, 2L, 3L, 4L,
5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L,
19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L,
32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L,
45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L,
58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L, 68L, 69L, 70L,
71L, 72L, 73L, 74L, 75L, 76L, 77L, 78L, 79L, 80L, 81L, 82L, 83L,
1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L,
15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L,
28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L,
41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L,
54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L,
67L, 68L, 69L, 70L, 71L, 72L, 73L, 74L, 75L, 76L, 77L, 78L, 79L,
80L, 81L, 82L, 83L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 10L, 11L,
12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 25L, 26L,
27L, 28L, 29L, 30L, 31L, 32L, 34L, 35L, 36L, 38L, 39L, 41L, 42L,
43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 55L, 56L, 57L,
59L, 60L, 61L, 62L, 64L, 66L, 67L, 68L, 69L, 70L, 73L, 74L, 75L,
76L, 77L, 78L, 79L, 81L, 82L, 83L, 1L, 2L, 3L, 4L, 5L, 6L, 7L,
8L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L,
22L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 34L, 35L, 36L, 38L,
39L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L,
55L, 56L, 57L, 59L, 60L, 61L, 62L, 64L, 66L, 67L, 68L, 69L, 70L,
73L, 74L, 75L, 76L, 77L, 78L, 79L, 81L, 82L, 83L, 2L, 3L, 4L,
5L, 6L, 7L, 8L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 19L,
20L, 21L, 22L, 23L, 24L, 25L, 26L, 28L, 30L, 33L, 34L, 36L, 38L,
39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L,
52L, 55L, 56L, 57L, 58L, 60L, 62L, 63L, 64L, 65L, 66L, 67L, 68L,
70L, 71L, 73L, 74L, 75L, 76L, 77L, 78L, 79L, 81L, 82L, 83L, 2L,
3L, 4L, 5L, 6L, 7L, 8L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L,
19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 28L, 30L, 33L, 34L, 36L,
38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L,
51L, 52L, 55L, 56L, 57L, 58L, 60L, 62L, 63L, 64L, 65L, 66L, 67L,
68L, 70L, 71L, 73L, 74L, 75L, 76L, 77L, 78L, 79L, 81L, 82L, 83L,
1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 10L, 11L, 12L, 13L, 14L, 16L,
17L, 19L, 20L, 21L, 22L, 25L, 26L, 27L, 28L, 30L, 31L, 32L, 33L,
34L, 35L, 36L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L,
48L, 49L, 50L, 51L, 52L, 55L, 56L, 57L, 58L, 60L, 61L, 63L, 65L,
66L, 67L, 68L, 70L, 71L, 73L, 74L, 75L, 76L, 77L, 78L, 79L, 81L,
82L, 83L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 10L, 11L, 12L, 13L,
14L, 16L, 17L, 19L, 20L, 21L, 22L, 25L, 26L, 27L, 28L, 30L, 31L,
32L, 33L, 34L, 35L, 36L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L,
46L, 47L, 48L, 49L, 50L, 51L, 52L, 55L, 56L, 57L, 58L, 60L, 61L,
63L, 65L, 66L, 67L, 68L, 70L, 71L, 73L, 74L, 75L, 76L, 77L, 78L,
79L, 81L, 82L, 83L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 10L, 11L,
12L, 13L, 14L, 16L, 17L, 19L, 20L, 21L, 22L, 25L, 27L, 28L, 30L,
32L, 35L, 36L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 47L, 48L,
49L, 50L, 51L, 52L, 58L, 60L, 61L, 62L, 63L, 65L, 66L, 67L, 68L,
73L, 74L, 77L, 78L, 79L, 81L, 82L, 1L, 2L, 3L, 4L, 5L, 6L, 7L,
8L, 10L, 11L, 12L, 13L, 14L, 16L, 17L, 19L, 20L, 21L, 22L, 25L,
27L, 28L, 30L, 32L, 35L, 36L, 38L, 39L, 40L, 41L, 42L, 43L, 44L,
45L, 47L, 48L, 49L, 50L, 51L, 52L, 58L, 60L, 61L, 62L, 63L, 65L,
66L, 67L, 68L, 73L, 74L, 77L, 78L, 79L, 81L, 82L), .Label = c("ace",
"adm", "aim", "ali", "all", "ana", "ann", "apr", "arl", "ast",
"bob", "bra", "bri", "brn", "brt", "cas", "cat", "cha", "cla",
"con", "ctr", "dav", "dea", "dev", "dia", "don", "emi", "eth",
"fra", "geo", "gil", "gre", "guy", "ina", "jac", "jam", "jas",
"jea", "jeb", "jen", "jer", "jes", "joe", "joy", "jus", "kar",
"kev", "kur", "mar", "may", "meg", "mel", "mia", "mit", "mon",
"mor", "mrk", "ned", "nic", "pau", "pet", "ras", "rau", "rem",
"ril", "roc", "ros", "sar", "sea", "shl", "sho", "sop", "stn",
"sus", "tam", "ter", "tod", "tom", "tri", "tru", "vic", "zan",
"zen"), class = "factor"), Turns = c(63L, 349L, 806L, 427L, 440L,
559L, 341L, 76L, 190L, 719L, 260L, 492L, 228L, 110L, 229L, 234L,
209L, 549L, 89L, 252L, 172L, 506L, 202L, 372L, 614L, 230L, 328L,
431L, 164L, 691L, 202L, 293L, 434L, 385L, 119L, 215L, 85L, 312L,
263L, 526L, 298L, 404L, 165L, 281L, 444L, 437L, 206L, 428L, 75L,
647L, 770L, 295L, 255L, 262L, 190L, 224L, 356L, 293L, 453L, 313L,
317L, 275L, 426L, 382L, 363L, 572L, 349L, 436L, 236L, 219L, 260L,
41L, 333L, 87L, 392L, 442L, 313L, 806L, 497L, 528L, 393L, 393L,
650L, 213L, 313L, 625L, 554L, 333L, 1156L, 544L, 521L, 252L,
571L, 323L, 554L, 504L, 233L, 407L, 365L, 403L, 627L, 286L, 512L,
336L, 833L, 566L, 431L, 645L, 302L, 837L, 494L, 362L, 810L, 343L,
470L, 522L, 490L, 253L, 227L, 250L, 462L, 386L, 593L, 525L, 681L,
255L, 371L, 568L, 793L, 516L, 734L, 368L, 816L, 1106L, 438L,
364L, 475L, 282L, 469L, 481L, 487L, 856L, 453L, 517L, 372L, 516L,
603L, 533L, 918L, 121L, 460L, 234L, 420L, 617L, 90L, 807L, 321L,
1111L, 733L, 781L, 863L, 695L, 828L, 658L, 391L, 852L, 256L,
534L, 188L, 147L, 241L, 290L, 366L, 102L, 222L, 226L, 318L, 248L,
353L, 315L, 375L, 379L, 258L, 187L, 204L, 178L, 341L, 695L, 205L,
293L, 414L, 141L, 282L, 112L, 134L, 579L, 283L, 461L, 326L, 543L,
248L, 355L, 227L, 234L, 276L, 536L, 285L, 391L, 106L, 788L, 658L,
431L, 187L, 200L, 126L, 560L, 153L, 622L, 343L, 421L, 291L, 565L,
248L, 282L, 152L, 382L, 185L, 140L, 229L, 222L, 753L, 489L, 550L,
58L, 367L, 381L, 628L, 302L, 303L, 228L, 783L, 666L, 492L, 124L,
298L, 466L, 483L, 564L, 390L, 453L, 662L, 140L, 530L, 341L, 240L,
472L, 815L, 256L, 520L, 640L, 297L, 462L, 278L, 340L, 873L, 479L,
364L, 429L, 647L, 380L, 558L, 455L, 391L, 299L, 1134L, 541L,
465L, 312L, 807L, 669L, 600L, 331L, 419L, 328L, 1014L, 218L,
877L, 494L, 726L, 646L, 425L, 336L, 622L, 428L, 1048L, 512L,
403L, 510L, 487L, 709L, 540L, 484L, 304L, 813L, 580L, 211L, 436L,
386L, 229L, 637L, 163L, 317L, 463L, 446L, 347L, 534L, 325L, 329L,
473L, 95L, 206L, 187L, 436L, 464L, 582L, 435L, 44L, 441L, 665L,
606L, 422L, 695L, 470L, 473L, 543L, 453L, 505L, 348L, 505L, 212L,
445L, 230L, 365L, 324L, 752L, 537L, 438L, 380L, 91L, 252L, 261L,
260L, 483L, 434L, 348L, 531L, 266L, 856L, 372L, 89L, 239L, 345L,
328L, 80L, 553L, 395L, 754L, 540L, 570L, 322L, 288L, 735L, 186L,
415L, 238L, 367L, 894L, 390L, 157L, 707L, 490L, 442L, 481L, 407L,
217L, 598L, 263L, 301L, 144L, 526L, 953L, 954L, 451L, 43L, 510L,
1256L, 393L, 424L, 534L, 653L, 618L, 397L, 547L, 829L, 301L,
583L, 103L, 540L, 324L, 396L, 513L, 453L, 524L, 727L, 362L, 484L,
210L, 268L, 270L, 463L, 479L, 336L, 635L, 286L, 672L, 566L, 156L,
250L, 627L, 622L, 244L, 610L, 427L, 892L, 703L, 404L, 415L, 341L,
99L, 240L, 48L, 131L, 269L, 316L, 313L, 42L, 113L, 43L, 300L,
107L, 275L, 155L, 90L, 123L, 278L, 181L, 465L, 289L, 160L, 133L,
719L, 478L, 351L, 126L, 230L, 300L, 178L, 365L, 234L, 217L, 297L,
424L, 185L, 187L, 273L, 73L, 248L, 60L, 293L, 45L, 561L, 392L,
300L, 128L, 97L, 373L, 65L, 307L, 376L, 136L, 167L, 108L, 368L,
358L, 261L, 335L, 43L, 128L, 248L, 145L, 293L, 272L, 324L, 209L,
208L, 330L, 101L, 286L, 53L, 97L, 247L, 478L, 301L, 239L, 61L,
12L, 277L, 102L, 251L, 62L, 54L, 150L, 318L, 244L, 534L, 410L,
162L, 134L, 1042L, 499L, 505L, 92L, 324L, 396L, 267L, 378L, 319L,
234L, 453L, 398L, 305L, 207L, 214L, 33L, 288L, 66L, 347L, 51L,
503L, 617L, 304L, 156L, 158L, 466L, 74L, 399L, 451L, 235L, 172L,
104L, 136L, 466L, 485L, 357L, 40L, 196L, 336L, 190L, 381L, 268L,
224L, 215L, 150L, 534L, 183L, 539L, 60L, 221L, 404L, 80L, 250L,
113L, 277L, 451L, 598L, 257L, 245L, 58L, 199L, 19L, 363L, 195L,
644L, 185L, 685L, 593L, 337L, 181L, 316L, 416L, 165L, 837L, 288L,
457L, 562L, 264L, 331L, 143L, 208L, 166L, 180L, 591L, 284L, 259L,
207L, 377L, 432L, 362L, 227L, 341L, 69L, 319L, 293L, 203L, 150L,
361L, 853L, 300L, 643L, 362L, 73L, 596L, 121L, 97L, 218L, 279L,
217L, 268L, 54L, 453L, 480L, 283L, 329L, 93L, 288L, 92L, 400L,
155L, 709L, 217L, 720L, 493L, 818L, 316L, 212L, 140L, 353L, 849L,
326L, 447L, 636L, 221L, 191L, 29L, 381L, 205L, 376L, 314L, 231L,
443L, 181L, 145L, 307L, 304L, 353L, 328L, 185L, 105L, 218L, 560L,
430L, 324L, 779L, 319L, 377L, 159L)), class = c("grouped_df",
"tbl_df", "tbl", "data.frame"), row.names = c(NA, -686L), groups = structure(list(
Age = c(1, 1, 2, 2, 3, 3, 5, 5, 7, 7), Speaker = c("CHI",
"MOT", "CHI", "MOT", "CHI", "MOT", "CHI", "MOT", "CHI", "MOT"
), .rows = structure(list(1:83, 84:166, 167:235, 236:304,
305:371, 372:438, 439:506, 507:574, 575:630, 631:686), ptype = integer(0), class = c("vctrs_list_of",
"vctrs_vctr", "list"))), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -10L), .drop = TRUE))
[1]: https://i.stack.imgur.com/i6t1A.png
[1]: https://i.stack.imgur.com/nbxAd.png
</details>
# 答案1
**得分**: 2
由于您的数据包含多个 `Speaker`,您最终会得到多个关于 `name` 的观察结果。因此,要去掉垂直线,您需要考虑 `Speaker`,例如通过根据 `Speaker` 和 `name` 的交互分组来实现:
```R
library(ggplot2)
ggplot(sum_data, aes(
x = Age, y = Turns,
group = paste(Name, Speaker, sep = "."), color = Speaker
)) +
geom_line()
[![输入图像描述][1]][1]
[1]: https://i.stack.imgur.com/lwbxx.png
<details>
<summary>英文:</summary>
As your data contains multiple `Speaker`s you end up with multiple obs. per `name`. Hence, to get rid of the vertical lines you have to take the `Speaker`s into account by e.g. grouping by the interaction of `Speaker` and `name`:
library(ggplot2)
ggplot(sum_data, aes(
x = Age, y = Turns,
group = paste(Name, Speaker, sep = "."), color = Speaker
)) +
geom_line()
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/lwbxx.png
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论