-1

I am trying to make a boxplot R. I have two loaded data frames- both of which have a column titled MEANS. I am trying to create a box and whiskers plot comparing both of the columns titled MEANS for both of these data frames in preparation to run an ANOVA. What is the most straight forward way to do this?

Lee Drown
  • 35
  • 2
  • 6
  • 1
    *I have two loaded data frames* ... please [share the data](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5965451). *I am trying* ... please share your attempted code and any issues (i.e., errors, undesired results). – Parfait Oct 04 '19 at 17:28

2 Answers2

0

if the object names are 'df1', 'df2', then load this into a list, extract the column and apply boxplot

lapply(mget(paste0("df", 1:2)), function(x) boxplot(x$MEANS))
akrun
  • 874,273
  • 37
  • 540
  • 662
0

I would combine the two data frames into a single dataframe, then plot:

df1 <- data.frame(data = rep("data1",100),MEANS = rnorm(100))
df2 <- data.frame(data = rep("data2",100),MEANS = rnorm(100))

df <- rbind(df1,df2)

boxplot(data = df, MEANS ~ data)
johnckane
  • 645
  • 8
  • 18