Without actual data, it is difficult to show you the exact code you need to use, but after having a glimpse at that png
, I would suggest you try something along the following lines:
library(reshape2)
library(ggplot2)
df <- melt(your_data)
ggplot(df, aes(x=variable, y=value)) + geom_boxplot()
This code probably needs some adjustment. If it doesn't work and the adjustments are not obvious, please post some example data in a way that makes it easy for us to use it. Data from a screenshot would imply we have to manually copy-paste each and every number, which few would be willing to do.
To clarify the general procedure: melt
"stacks" all your columns on top of each other and adds a variable called variable
, which refers to the old column name. You can hand this over to ggplot
and say that the different values of variable
should be on the x
axis, which is what you want. For instance, have a look at women
:
head(women)
height weight
1 58 115
2 59 117
3 60 120
4 61 123
5 62 126
6 63 129
str(women)
'data.frame': 15 obs. of 2 variables:
$ height: num 58 59 60 61 62 63 64 65 66 67 ...
$ weight: num 115 117 120 123 126 129 132 135 139 142 ...
You see that women
is a dataframe with 15 observations and two columns, height
and weight
.
Now, let's melt
them:
df <- melt(women)
head(df)
variable value
1 height 58
2 height 59
3 height 60
4 height 61
5 height 62
6 height 63
str(df)
'data.frame': 30 obs. of 2 variables:
$ variable: Factor w/ 2 levels "height","weight": 1 1 1 1 1 1 1 1 1 1 ...
$ value : num 58 59 60 61 62 63 64 65 66 67 ...
Now you see it has 30 observations, and two columns: variable
and value
. variable
identifies the old columns.
Let's hand this over to ggplot
:
ggplot(df, aes(x=variable, y=value)) + geom_boxplot()
yields:

Here you have boxplots for both columns in the original women
dataset.