Search code examples
rvariablesggplot2plotboxplot

ggplot & boxplot: is it possible draw a box plot with different variables?


Is it possible to draw a bow plot with different variables, considering that these variable are in different datasets?

I'd like to draw a box for each one of them to make a comparison


Solution

  • Depends what you mean by different variables.

    You could do something like this.

    ggplot()+
    geom_boxplot(data=df_1, aes(x=x, y=y))+
    geom_boxplot(data=df_2, aes(x=x, y=y))
    

    This is not ideal better to combine the datasets with rbind() or merge().

    If it is a list you can use do.call("rbind", df) to combine all the elements of the list into one dataframe.