I have a dataset that looks like this
data=
**ID HbA1cRes Year**
1 65 2003
2 125 2008
3 40 2010
4 110 2007
5 125 2006
6 136 2011
7 20 2012
8 58 2009
9 12 2006
10 123 2008
The patients with HbA1cRes > 65 are classified as 'High risk' and the ones below that are classified as 'Low Risk'. I am trying to do a time series analysis using the following code (to see the rise and fall of high risk and low-risk cases over time) and Year <- data$REport_YrMonth
library(tidyverse)
data$risk <- factor( ifelse( data$HbA1cRes > 65 ,"High risk patients", "Low risk patients") )
ggplot(data, aes(x=Year)) +
geom_line(aes(y=risk)) +
labs(title="Analysis of diabetes' patients status over time",
y="Returns %")
However, the output returned is as follows:
Any guess what I am doing wrong here?