You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this session we will use two related fictive datasets. The first one, called `experiment2017` is an on farm experiment, where each of 20 farmers has collected values of yield for two plots, one where a new treatment has been applied (column "Treatment"), and one where this new treatment has not been applied (column "Control"). You can download this dataset [here](https://github.com/stats4sd/R4CCRP_08Merge/raw/main/experiment2017.csv)
56
+
In this session we will use two related fictive datasets. The first one, called `experiment2017` is an on farm experiment, where each of 20 farmers has collected values of yield for two plots, one where a new treatment has been applied (column "Treatment"), and one where this new treatment has not been applied (column "Control").
60
57
61
-
The other dataset called `interview2019` contains the responses of 71 farmers - some of which participated in the 2017 experiment - when asked whether they would accept to participate to a new experiment (column "Accept"). You can download this dataset [here](https://github.com/stats4sd/R4CCRP_08Merge/raw/main/interview2019.csv)
58
+
The other dataset called `interview2019` contains the responses of 71 farmers - some of which participated in the 2017 experiment - when asked whether they would accept to participate to a new experiment (column "Accept"). You can download these two datasets [here](https://github.com/stats4sd/R4CCRP_08Merge/raw/main/data-merge.zip)
62
59
63
60
Our goal will be to combine these two datasets in order to explore whether for a farmer, the outcome of the 2017 experiment is related to their willingness to participate in a new experiment.
And if you think to when we've used `ggplot2`, we always had one unique variable for our y argument, and we used categorical variables to separate it into groups, facets, colours and it was similar for modelling. We had one dependant variable only and the groups of the Anova were defined by come categorical variable. So in general long formats work much better than wide formats for making graphs or doing some statistical modelling.
169
166
170
167
171
-
And to help us analyse our dataframe `MergedData` where the experimental data is in long format, we should turn it into long format.
168
+
And to help us analyse our dataframe `MergedData` where the experimental data is in wide format, we should turn it into long format.
172
169
173
170
The `pivot_longer()` function from the `tidyr` library allows us to do this.
174
171
@@ -217,7 +214,7 @@ LongData %>%
217
214
```
218
215
Notice that it is the group aesthetics that define which are the points connected by the lines. In our case, these are the points corresponding to a same farmer.
219
216
220
-
We can see that most of the lines that go down are red, that is most of the farmers who saw a decrease in yield between the control and treatment plots during the 2017 experiment, did not want to participate in a new experiment according to the 2019 interview. In contrast, the lines that go up seem to often be blue. This might be easier to see using facets:
217
+
We can see that most of the lines that go down are red, that is most of the farmers who saw a decrease in yield between the control and treatment plots during the 2017 experiment, did not want to participate in a new experiment according to the 2019 interview. In contrast, the lines that go up are blue. This might be easier to see using facets:
<p>In this session we will use two related fictive datasets. The first one, called <code>experiment2017</code> is an on farm experiment, where each of 20 farmers has collected values of yield for two plots, one where a new treatment has been applied (column “Treatment”), and one where this new treatment has not been applied (column “Control”).</p>
135
-
<p>The other dataset called <code>interview2019</code> contains the responses of 71 farmers - some of which participated in the 2017 experiment - when asked whether they would accept to participate to a new experiment (column “Accept”).</p>
134
+
<p>In this session we will use two related fictive datasets. The first one, called <code>experiment2017</code> is an on farm experiment, where each of 20 farmers has collected values of yield for two plots, one where a new treatment has been applied (column “Treatment”), and one where this new treatment has not been applied (column “Control”). You can download this dataset <ahref="https://github.com/stats4sd/R4CCRP_08Merge/raw/main/experiment2017.csv">here</a></p>
135
+
<p>The other dataset called <code>interview2019</code> contains the responses of 71 farmers - some of which participated in the 2017 experiment - when asked whether they would accept to participate to a new experiment (column “Accept”). You can download this dataset <ahref="https://github.com/stats4sd/R4CCRP_08Merge/raw/main/interview2019.csv">here</a></p>
136
136
<p>Our goal will be to combine these two datasets in order to explore whether for a farmer, the outcome of the 2017 experiment is related to their willingness to participate in a new experiment.</p>
137
137
<p>You can have a look at the <code>experiment2017</code> dataset here:</p>
0 commit comments