2021年5月2日星期日

Making groups from 2 different datasets in ggboxplot using R

I currently have been making box plots to represent my data to show the difference between RATE for 2 different treatments, CALC_ACT = Yes or No, but have only been using one dataset at a time. I currently have two different datasets that I want to compare but don't know how to put them in the one boxplot.

I have shown below how I am using ggboxplot to represent a single dataset (PatientData).

What I would like is for that dataset to be grouped together and then the same data from my second dataset (PatientData2) to be on the plot next to it with the label of the dataset underneath each section.

Hopefully this makes sense... any tips?

PatientData <- data.frame(PATIENT_ID = c(1,1,2,2,3,3,4,4), CALC_ACT = c("No","Yes","No","Yes","No","Yes","No","Yes"), RATE = c(1,0.1,0.5,0.6,0.8,1,0.5,0.4))  PatientData2 <- data.frame(PATIENT_ID = c(5,5,6,6,7,7,8,8), CALC_ACT = c("No","Yes","No","Yes","No","Yes","No","Yes"), RATE = c(.4,1,0.5,0.6,0.3,0.8,0.6,0.4))    ggboxplot(PatientData, x = "CALC_ACT", y = "RATE",             color = "CALC_ACT", palette = c("#00AFBB", "#E7B800"),            order = c("No", "Yes"),            ylab = "Rate", xlab = "Calcium")  
https://stackoverflow.com/questions/67362643/making-groups-from-2-different-datasets-in-ggboxplot-using-r May 03, 2021 at 09:49AM

没有评论:

发表评论