Hi have a small pilot data set of 5 Patients, 16 Controls and 52 variables in SPSS format. I need to generate a ggplot2, a boxplot with jitter for EACH variable (controls and patients combined). But I need the controls data points and the patients datapoints to be in different colors/symbols in R. I’m very new to R so I don’t know what the code is. Attached are examples of box plot I need.
Example Boxplot
This is the Code I have this instruction but I can’t understand how to customize it. My dataset is called “Test2”, My “Group” variable is the contains “Patient” and “Control” and the other variables are named FOD_1, FOD_2…etc.
ggplot(data, aes(x = Variable, y = Value, color = Group, shape = Group)) +
geom_boxplot(outlier.shape = NA, alpha = 0.5) + # Boxplot without outliers, transparency for clarity
geom_jitter(position = position_jitter(width = 0.2), size = 2) + # Jitter for better visibility of points
theme_bw() + # Clean theme
theme(axis.text.x = element_text(angle = 90, hjust = 1)) + # Rotate x-axis labels
labs(title = "Boxplots with Jitter for Each Variable", x = "Variable", y = "Value")
Meenakshi Rozenstrauch is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2