Correction for multiple observations for the same variable in R analysis

I have a dataframe of pre- and post-treatment serum lipid levels from 9 patients that I am trying to analyze in R. I want to see if a patient's baseline lipid level can predict the response to a class of medication, however, I am running into an issue where some patients received two different drugs and showed different responses to each drug. Below is an example of the dataset:

    id prepost    lipid    conc  treatment_x  treatment_y  treatment_x_y_combo          
  1  1     pre  lipid x   36097           NR            R                   NA                       
  2  2     pre  lipid x   17667           NR           NR                   NA                       
  3  3     pre  lipid x   17949           NR            R                   NA                       
  4  4     pre  lipid x   18839           NR            R                   NA                       
  5  5     pre  lipid x   10965           NR           NA                   NA                       
  6  6     pre  lipid x   40371           NA            R                   NA                       
  7  7     pre  lipid x   38086           NA            R                   NA                       
  8  8     pre  lipid x  118650           NA            R                   NA                       
  9  9     pre  lipid x   58279           NA           NA                   NR

For context, treatment x and treatment y are both in the same treatment class.

To answer my question, I was planning to run a t-test between responders (R) and non-responders (NR), I'm afraid I can't simply label each patient as an R or NR because some patients received two different drugs and showed two different responses to each drug. For example, id 1 received treatment x and y. They didn't respond to treatment x but responded to treatment y.

I tried to focus on just one treatment (i.e. treatment x) rather than the class of treatment, but it appears that all patients that received treatment x did not respond and all patients that received drug y responded, except for one.

I'm relatively new to R and data analysis in general, so I apologize if I am not explaining any of this correctly. I was hoping someone had any suggestions as to what I should do next. Is there a way to transform the data to correct the issue of different responses to different drugs? Or is there a test I could run that would take the multiple observations into account?

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.