I have a dataframe (20 variables (diagnostic codes) with 43 measurements each)--in which the row number corresponds to the day of the measurement (sort of like time series data) .
I want to plot the measurement over time (ie from day 1 to day 43) for each variable.
I tried first creating a new variable called days so that I could plot it as the x-axis
tarp_d<-tarp_t %>% mutate(days=1:43)
But now I'm having a hard time figuring out how to plot all of the 20 variables in one plot, without having to add each variable individually like:
ggplot(tarp_d, aes(x=days))+geom_point(aes(y=TP21A))+geom_point(aes(x=days, y=TP26A))
Does anyone know how to automate this? Or know of a way in which I can directly use the row number as the x-axis without having to create a new variable? I also thought of
And, for the record this is the structure:
> str(tarp_s) 'data.frame': 43 obs. of 21 variables:
$ TP21A: num 1.42 1.36 1.3 1.25 1.19 ...
$ TP21B: num 1.39 1.33 1.28 1.22 1.17 ...
$ TP24A: num 1.88 1.82 1.75 1.69 1.62 ...
$ TP24B: num 1.67 1.6 1.54 1.47 1.41 ...
$ TP25A: num 1.4 1.4 1.4 1.4 1.4 ...
$ TP25B: num 1.33 1.3 1.26 1.23 1.2 ...
$ TP26A: num 1.51 1.49 1.48 1.46 1.44 ...
$ TP26B: num 1.46 1.43 1.4 1.36 1.33 ...
$ TP27A: num 1.86 1.85 1.84 1.84 1.83 ...
$ TP27B: num 1.53 1.48 1.44 1.39 1.34 ...
$ TP27C: num 1.42 1.39 1.35 1.31 1.27 ...
$ TP28A: num 1.66 1.65 1.64 1.63 1.62 ...
$ TP28B: num 1.38 1.35 1.31 1.28 1.24 ...
$ TP29A: num 1.47 1.47 1.47 1.47 1.47 ...
$ TP29B: num 1.46 1.42 1.37 1.33 1.28 ...
$ TP30A: num 1.48 1.48 1.48 1.48 1.48 ...
$ TP30B: num 1.25 1.25 1.25 1.25 1.25 ...
$ TP30C: num 1.03 1.03 1.03 1.03 1.03 ...
$ TP70Z: num 1.31 1.31 1.31 1.31 1.31 ...
$ TP96Z: num NA NA NA NA NA NA NA NA NA NA ...
$ days : num 1 2 3 4 5 6 7 8 9 10 ...