r - Simplest way to do grouped barplot -


i have following dataframe:

 catergory        reason species 1   decline       genuine      24 2  improved       genuine      16 3  improved misclassified      85 4   decline misclassified      41 5   decline     taxonomic       2 6  improved     taxonomic       7 7   decline       unclear      41 8  improved       unclear     117 

i'm trying make grouped bar chart, species height , 2 colours catergory.

i post image of i've got, don't have enough reputation points... here code:

reasonstats<-read.csv("bothstats.csv") reasonstats2<-as.matrix(reasonstats[,3])   barplot((reasonstats2),beside=t,col=c("darkblue","red"),ylab="number of  species",names.arg=reasonstats$reason, cex.names=0.8,las=2,space=c(0,100) ,ylim=c(0,120)) box(bty="l") 

now want, not have label 2 bars twice , group them apart, i've tried changing space value sorts of things , doesn't seem move bars apart. can anyoen tell me i'm doing wrong?

with ggplot2:

library(ggplot2) animals <- read.table(   header=true, text='category        reason species 1   decline       genuine      24 2  improved       genuine      16 3  improved misclassified      85 4   decline misclassified      41 5   decline     taxonomic       2 6  improved     taxonomic       7 7   decline       unclear      41 8  improved       unclear     117')  ggplot(animals, aes(factor(reason), species, fill = category)) +    geom_bar(stat="identity", position = "dodge") +    scale_fill_brewer(palette = "set1") 

bar chart


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -