Posts

Showing posts with the label line-plot

Using the “aggregate” function for drawing line plots

Image
Clash Royale CLAN TAG #URR8PPP Using the “aggregate” function for drawing line plots I am trying to draw a line plot with error bars for two groups of data (Treatment vs. Control). There are totally 20 periods, 10 Trial Periods (TP) and 10 formal Periods (P) and I want to show how the group means change over time. For simplicity, the following dataframe includes 3 Trial Periods (TP1, TP5, TP10) and 3 formal Periods (P1, P5, P10). Below is my code. My problem is that the “aggregate” function changes the order of the periods by resorting them as strings, which messes up the time trend—I want them to be ordered as TP1->TP5->TP10->P1->P5->P10 I suppose this is not too tricky, but I’m just stuck. I’d appreciate it if someone could tell me how to solve this problem. Also: as there are 20 periods in total, it might look better to draw error bands (or CI bands) instead of numerous error bars. Is there a way to do this? df <- data.frame(Condition=c(rep("Treatment...