Hi,
I have a data for which I have to get the line graph. Basically it's the data of performance of students from first, second and third exams. I need to track the students who get less that 85% and who deteriorate from first to second exams. But when I get the graph, the legends show the color of all the students as given below. I want the color enumerators who are shown in the graph.
How can I do this?
library(tidyverse)
data<-tibble::tribble(
~id, ~obs_num, ~score,
"BEN001", 1L, 84L,
"BEN001", 2L, 85L,
"BEN002", 1L, 86L,
"BEN002", 2L, 86L,
"BEN002", 3L, 84L,
"BEN003", 1L, 88L,
"BEN003", 2L, 90L,
"BEN004", 1L, 80L,
"BEN004", 2L, 80L,
"BEN005", 1L, 83L,
"BEN005", 2L, 88L,
"BEN006", 1L, 79L,
"BEN006", 2L, 80L
)
data %>%
filter(score<85) %>%
ggplot(aes(obs_num,score,group=id,color=as.factor(id)))+
geom_line()
Created on 2022-08-17 by the reprex package (v2.0.1)