1

I simply wanted to create a boxplot of three numeric columns of a dataframe in R. The dataframe looks like this:

  no_filter                      filter1                   filter2
1 0.7223437                    0.7376562                    0.7418750
2 0.7223437                    0.7376562                    0.7418750
3 0.7262500                    0.7276562                    0.7289062

I had a look here How to create one box plot using multiple columns and argument "split", but didn't really get my head around it. So if anyone has an idea, would be super appreciated. In the best case with gpplot

1 Answer 1

3

With ggplot, we may need to reshape into 'long' format

library(dplyr)
library(tidyr)
df1 %>% 
  pivot_longer(cols = everything()) %>% 
  ggplot(aes(x = name, y = value)) +
      geom_boxplot()

enter image description here

###data

df1 <- structure(list(no_filter = c(0.7223437, 0.7223437, 0.72625), 
    filter1 = c(0.7376562, 0.7376562, 0.7276562), filter2 = c(0.741875, 
    0.741875, 0.7289062)), class = "data.frame", row.names = c("1", 
"2", "3"))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.