Reputation: 131
My goal is to visualize some data frames with ggplot2
.
I have several data.frames looking like this
And my goal is a boxplot looking like this, just nicer.
I managed to get single boxplots using
plt <- ggplot(data, aes(RF, data$RF)) +
geom_boxplot()
plt
But that's not what I want.
Upvotes: 0
Views: 2092
Reputation: 277
I guess this is what you want:
library(ggplot2)
library(reshape)
myddt_m = melt(mydata)
names(myddt_m)=c("Models","CI")
ggplot(myddt_m, aes(Models, CI,fill=Models )) + geom_boxplot()+guides(fill=FALSE)+labs( x="", y="C-Index")
Upvotes: 2
Reputation: 268
library(ggplot2)
library(reshape)
airquality_m = melt(airquality)
ggplot(airquality_m, aes(variable, value )) + geom_boxplot()
I did not beautify the plot but I guess you get the idea here.
Upvotes: 3
Reputation: 5555
That boxplot you showed is created with base-r graphics. Single command
boxplot(data)
will do it.
If you want to use ggplot
, you have to first melt
the dataframe and then plot.
library(reshape2)
datPlot <- melt(data)
ggplot(datPlot,aes(variable,value)) + geom_boxplot()
Upvotes: 3