9. Final exercise

Here you will find a dataset in .csv format containing the results of a study performed to investigate the impact of three anorexia treatments (the source of these data can be found here, p. 9). The weights of (in total) 72 anorexia patients were measured before and after receiving one of the three treatments.

The data contain three variables:

Please perform the steps below to analyze these data. Don’t forget to annotate your script. Again, feel free to use any on-line information you can find.

  1. Import the data into R, and store it as an object.

  2. Check the first three rows of the data to see if step 1 was performed correctly.

  3. Create two new variables representing the weight in kilograms (instead of lbs). Note: 1 kg = 2.205 lbs.

  4. Calculate weight change, i.e. the weight after receiving the treatment minus the change before receiving the treatment, and add this information to the dataset.

  5. Make three box plots of the change scores, one for each treatment.

  6. Calculate the average weight change for each of the treatments.

  7. Add a new variable to the dataset indicating whether the weight was decreased, increased or remained approximately the same. Let the variable take on the character value ‘Decrease’ (if weight was decreased by at least 1 kg), ‘No change’ (if the change in weight was at most 1 kg in either direction), or ‘Increase’ (if the increase in weight was at least 1 kg).

  8. For each treatment, create a frequency table for the variable included in step 7.

  9. Note that the total number of patients assigned to each treatment differs. Hence, it is more informative to compare proportions instead of absolute numbers. Calculate, again per treatment, the proportion of patients in each category of the variable created in step 7.

  10. Write a short conclusion regarding the effectiveness of the three treatments.


The solution to this exercise can be found here.