Summarizing, I have the following dataset (description below)
Lastpage | Complete | Percentage_Complete | Age | Course
01 | 0| 0.023| 13| 2
21 | 0| 0.500| 14| 2
33 | 0| 0.786| 14| 3
42 | 1| 1.000| 15| 3
42 | 1| 1.000| 16| 4
- LastPage : The last page of the survey on individual characteristics that the subject completed (from 1 to 42)
- Complete : Equal to 1 of the subject filled all 42 pages of the questionnaire, 0 otherwise
- Percentage_Complete (Perc_Compl) : Percentage of the survey that the subject completed. If subject stopped at page X, it is equal to X/42.
- Age : Age of the subject. Equal to 13,14,15 or 16.
- Course : Course of the subject. Equal to 2,3 or 4.
I have a dataset of 200+ observations. When I want to display the density function by course, it works wonderfully with the following code :
ggplot(data_density, aes(x=perc_compl, color= course))+
But when I want to do it according to age with the following code :
ggplot(data_density, aes(x=perc_compl, color = age))+
It does not work, only drawing the overall density. I don't understand why and cannot find any beginning of an explanation, because this is the first time I am using a density function. I thought it could be because "age" needed to be a string, but stringing it is not a solution.
Edit : However, when I create a string variable taking values "thirteen, fourteen, fifteen, sixteen" according to age, it is working.
Can someone give me an explanation ?