Hi there,
Im stuck with my dataanalysis i R. I hope you can help. I am analyzing the impact of migrating from rural to urban areas in Tanzania and want to make a dietary diversity score for rural households before they migrate and after they migrate. I divided every fooditem into 10 groups. If the household consume 5 or more groups they have dietary diversity.
Rice is in group 1, cassava is in group 1, sweet potatoes is in group 8 and so on. How do I do if I want to tell R to give household#1 a score of 1 if they consumed food from 5 or more groups and a 0 if not. Remember that plenty of foods are in under the same foodgroup but I am only interested in the intake of different foodgroups. So the household should not get 1 two times if they consumed food from the same group twice.
To give an example of how my data looks like, see below. There is 59 different fooditems divided in 10 foodgroups. E.g. household#1 has 59 rows. Thereafter comes household#2 and so on downwards. There is 281 households.
ID Fooditemvalue Foodgroups Did you consume (yes/no)
1 101 1 1
1 102 1 2
1 103 8 1
1 104 3 1
.....
2 101 1 2
2 102 1 1
How do I count the mean dietary diversity score (if the household consumes 5 or more foodgroups) from all of the household together and seperately? I would like to make a plot with dietary diversity score on the y-axis (from 1-10) and on the x-axis the different household (hh1rural, hh1urban;hh2rural, hh2urban; hh3rural, hh3urban...) and one plot with the mean dietary diversity score on the y-axis and on the x-axis rural households and urban households.
I hope you understand my question. Thank you so much in advance.