Need help Creating a New Variable

The dataset I am working with is in the long format (as opposed to wide). This format is useful for many reasons, but can make it challenging in repeated measures studies like the one I am working with, when I want to compare “before” and “after” measurements on the same individual, or an individual’s response under two conditions.

Each participant’s level of anxiety was recorded using the State-Trait Anxiety Index at each of the three time points in the study. One of the questions the researchers for the study asked is whether aromatherapy foot massage has a positive impact on anxiety. To address this question, we would need to see whether the anxiety scores observed improved from baseline to after the intervention. The researchers defined improvement as any change in anxiety score from baseline to after the intervention that was at least 3 points (e.g. moving from a score of 65 to 62 would be considered an improvement).

How would I use R to create a new vector (i.e. variable) called change that characterizes whether each study participant experienced an improvement or not in their anxiety score from baseline to after the intervention?

How would I report my complete R code (with #comments to help people understand the steps in my method) that is used to create this new vector, "change". As well, how would I use R to generate a table that summarizes the distribution of the change variable.

This is the biggest clue to me that you are asking us to do your homework for you...
FAQ: Homework Policy

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.