Trying to Create Two Side by Side Box Plots Using Data from the Same Variable in R

Trying to Create Two Side by Side Box Plots Using Data from the Same Variable in R

I'm new to R. I'm trying to create a boxplot for two different categories, however the results of those two categories are complied in the same variable. I've used the count function to order the variables so they align with the category they are for.

I would like to create two side-by-side boxplots in R using the same variable. The image contains the code I'm trying to use and the error message I receive. Image of my attempt

2

1 Answer

The "~" in your boxplot() function plots one variable against another (the first variable on the y-axis and the second on the x-axis). For a boxplot the x variable might be categorical.

You might try:

par(mfrow = c(1, 2))
boxplot(QuestionTwo$seizure[1:28])
boxplot(QuestionTwo$seizure[29:59])

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Sarah Jenkins
Author

Sarah Jenkins

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.