Closed cadlam closed 6 years ago
@cadlam We're going to go over joins and joining data in a week or so. As this might be more suited for the Davis R Users group, let's chat about this in class or if you can make it to Monday 10-12pm (same place as class), I can try to help you out.
I am working on some data about plant response to a treatment, with paired plots. I want to create a new column (using mutate?), with the difference in the response variable between the two paired plots, treatment and control. I have one column specifying the number of the pair (1, 2, ..., etc.), and another specifying whether the plot is a treatment or a control. Each row is a separate plot. So in the new column, I want the difference between the value for plot 1/control minus the value for plot 1/treatment, and the same for plot 2, etc. How do I get R to match the plot number from two rows, then subtract the control and treatment if the plot numbers match?
For the sake of example, my data looks like this:
Thanks!