R regression analysis: analyzing data for a certain ethnicity
问题 I have a data set that investigate depression among individuals with different ethnicities (Black, White, and Latina). I want to know how depression at baseline relates to depression at post with all ethnic groups, I did lm(depression_base ~ depression_post, data=Data Now, I want to look at the relationship by ethnicity. Ethnicity in my dataset is coded as 0 = White , 1 = Black , and 2 = Latina . I am thinking that I need to use the ifelse function, but I cannot seem to get it to work. Here