I am in trouble of creating plots in R. If I have data like
I want to create:
with x-axis be Sepal.length, Sepal.Width, Petal.Width, Petal.Length ,y-axis be different species and height be the values. And also fill each bar plot with different color according to y-axis.
Thank you!
So far, I have tried:
iris_mean <- aggregate(iris[,1:4], by=list(Species=iris$Species), FUN=mean)
library(reshape2)
df_mean <- melt(iris_mean, id.vars=c("Species"), variable.name = "Samples",
value.name="Values")
ggplot(df_mean,aes(Samples,Values))+
geom_bar(aes(fill=Species),stat="identity")+
facet_grid(Species~.,scale='free',space='free')+theme(panel.margin = unit(0.1, "lines"))
ggplot(df_mean,aes(x=Samples,y=Species,height =Values))+
geom_density_ridges2(aes(fill=Species),stat='identity',
scale=1.5,
alpha=0.1,
lty = 1.1)