0

I was able to create 2 separate boxplots for my data, but I would like to combine them both, and im having trouble doing so..

Here are the codes if you would like to run them to see the box plots

data3<- read.csv("~/Downloads/data (2).csv")
library(tidyverse)
view(data3)

boxplot(data3$CLJ~data3$group, dataset = data3, col = "orange", na.rm=TRUE, xlab= "group", ylab = "CLJ", ylim = c(0, 80), yaxs = "I") ## first box plot 

boxplot(data3$accuracy~data3$group, col = "yellow", na.rm=TRUE, xlab = "group", ylab = "accuracy", ylim = c(0, 80), yaxs = "I") ## second box plot 



structure(list(CLJ = c(39L, 21L, 43L, 24L, 16L, 28L, 45L, 46L, 
69L, 15L, 38L, 28L, 50L, 51L, 8L, 46L, 25L, 35L, 59L, 24L, 48L, 
44L, 33L, 27L, 51L, 49L, 70L, 53L, 46L, 26L, 49L, 39L, 23L, 52L, 
81L, 36L, 52L, 43L, 19L, 17L, 37L, 68L, 41L, 34L, 22L, 16L, 58L, 
73L, 77L, 37L), accuracy = c(18L, 25L, 23L, 22L, 20L, 14L, 31L, 
20L, 24L, 6L, 24L, 12L, 16L, 24L, 23L, 15L, 14L, 24L, 42L, 19L, 
27L, 13L, 23L, 6L, 28L, 30L, 22L, 33L, 12L, 21L, 38L, 16L, 17L, 
11L, 29L, 18L, 22L, 21L, 29L, 19L, 17L, 28L, 20L, 35L, 14L, 14L, 
35L, 30L, 18L, 37L), group = c("B", "B", "B", "B", "B", "B", 
"B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", 
"B", "B", "B", "B", "B", "B", "I", "I", "I", "I", "I", "I", "I", 
"I", "I", "I", "I", "I", "I", "I", "I", "I", "I", "I", "I", "I", 
"I", "I", "I", "I", "I")), row.names = c(NA, 50L), class = "data.frame")
Phil
  • 7,287
  • 3
  • 36
  • 66
Deema
  • 3
  • 2
  • Please provide a sample of your data. – Phil Mar 09 '21 at 16:18
  • my data is large and has multiple variables, the first code when run in r will open the data file I am using. otherwise, I don't know how to provide a sample. – Deema Mar 09 '21 at 16:30
  • Run `sample_data <- data3[1:50, c("CLJ", "accuracy", "group")]` To get a version of the data that you need in order to reproduce, and then run `dput(sample_data)`. Paste the output of `dput()` into your question in order to provide it. – Phil Mar 09 '21 at 16:35
  • You're using base graphics, so I suggest you try `par(mfrow=c(1,2))` before calling `boxplot` two times. See [`?par`](https://stat.ethz.ch/R-manual/R-devel/library/graphics/html/par.html) for more details on `mfrow=`. Other options include [`layout(.)`](https://stat.ethz.ch/R-manual/R-devel/library/graphics/html/layout.html) and `par(new=TRUE)` (though these are a bit more finicky, I suggest the `par` method for now.) – r2evans Mar 09 '21 at 16:59
  • This is a common question, please search the existing questions in stackoverflow for "boxplot side by side" and you'll find many candidates. Examples: https://stackoverflow.com/q/31619973/3358272, https://stackoverflow.com/q/61764430/3358272, https://stackoverflow.com/q/39986084/3358272. Good luck! – r2evans Mar 09 '21 at 17:01

0 Answers0