In my data set in R, respondents were exposed to a stimuli, and their reactions were studied at baseline, one hour after exposure, and two hours after. In R, I adjusted the data by baseline. Here is an example of what my data looks like:
stimuli_no base hour two_hour
1 0 0.02 -0.10
2 0 0.01 -0.03
3 0 -0.01 0.02
1 0 -0.05 -0.06
2 0 0.03 0.05
3 0 0.02 0.04
First thing I want to is get the mean of each time interval by the stimuli_no, which I did with this code:
transform(df, m_base = ave(base, stimuli_no), m_hour = ave(hour, stimuli_no), m_twoh = ave(two_hour, stimuli_no))
Now I want to make a line graph that has the time intervals of baseline, hour, and two hour on the x axis, and the scores on the y axis, with separate lines for each of the stimuli. Here is an example:
Is there a simple way to do this in R with my data as is, or do I need to restructure my data? If I need to restructure, how would I go about that?