0

My data is an imported excel file where the first column is the sample time and is the 'x-axis' and the remaining columns are the measurement. They are the same measurements but taken from different subjects.

A snapshot of how the data looks is below:

enter image description here

I can stack them up on ggplot manually using:

ggplot(P2ROKI, aes(x=P2ROKI$Time))+
  geom_point(aes(y=P2ROKI$P1, colour="P1"))+
  geom_point(aes(y=P2ROKI$P6, colour="P6")) + 
  geom_smooth(aes(y=P2ROKI$P1, colour="P1")) + 
  geom_smooth(aes(y=P2ROKI$P6, colour="P6"))

However I wondered if there was a simpler way where I could do it in one go?

Axeman
  • 32,068
  • 8
  • 81
  • 94
Kat
  • 23
  • 1
  • 4
  • 1
    Please don't share data as images. We can't use that. – Axeman Jul 13 '17 at 10:17
  • Look at the answers by rcs and ecerulm on [this question](https://stackoverflow.com/questions/3777174/plotting-two-variables-as-lines-using-ggplot2-on-the-same-graph). You should reshape your data. Also, never use `$` inside `aes`, just give the bare variable names instead. – Axeman Jul 13 '17 at 10:18
  • 1
    Thanks - I have managed to make it work. Your advice was very helpful – Kat Jul 13 '17 at 11:11
  • Great, good to hear. – Axeman Jul 13 '17 at 11:41

0 Answers0