I'm just a beginner with R and I've been having some trouble organising my data set.
I have a particular problem. I'm working with a data set from an agricultural survey. In this data set, subjects (farms) have different plots and in those plots have different crops. Something like this
| Subject | CropName | Area | 
|---|---|---|
| A | Corn | 2 | 
| A | Carrots | 2 | 
| A | Avocado | 0,5 | 
| A | Corn | 1 | 
| B | Grapes | 2 | 
| C | Carrots | 3 | 
As you can see, not all farms have the same crops and the same crops can be found in different plots of the same farm.
What I want to do is to sum up the values of each crop in a farm and separate them in different columns, to obtain only one observation per farm. Which will make my life easier on the analysis phase.
Something like this:
| Subject | Corn | Carrots | Avocado | Grapes | 
|---|---|---|---|---|
| A | 3 | 2 | 0.5 | 0 | 
| B | 0 | 0 | 0 | 2 | 
| C | 0 | 3 | 0 | 0 | 
I've have not idea how to do it. I'm open to suggestions about how my code should look like. Thanks a lot!
 
    