Stat Programming #homework
Hey all,
need some help with this homework problem.
I need to find the difference between 2 values in the same row, but two different columns, and then print different messages based on whether the difference is positive, negative, or 0.
I started by first creating a data frame :
df <- data.frame(patient = c(1 , 2 , 3 , 4 , 5 , 6, 7 , 8),
baseline=c(100,110,109,99,103,101,125,130),
follow_up = c(105, 100, 102, 105, 100, 97, 108, 120))
Then I created another column : df$difference <- df$baseline - df$follow_up
Now what I want to do is write code that would cycle through each element in the column I created, and print the appropriate text based on value with respect to 0.
How do I do this? Any help is greatly appreciated!