[R] Multivariable barplot

Domenico Vistocco vistocco at unicas.it
Tue Jan 22 12:50:00 CET 2008


Pilar Loren wrote:
> Hi, is it possible to do a multivariable barplot with ggplot2?
>
> I have something like that:
>
>   
>> df
>>     
>            LENGTH      LAT
> 091639  10.002   42.26282
> 091640  30.808   42.26834
> 091641   21.591  42.31689
> 091642   22.030  41.53246
> 091643   22.744  42.01954
> 091644   12.702  42.67751
> 091645   39.728  42.06479
> 091647   63.057  41.25283
> 091648   19.523  41.01925
> 091649   13.336  42.46904
> 091650    8.935   42.80971
> 091651    25.275 42.50678
> 091652    9.983   42.89345
> 091653    9.416   41.15288
>
>   
>> p <- ggplot(df)
>> p <- p + geom_bar(aes(x=rownames(df), y=LENGTH), position="dodge",
>>     
> fill="red")
>   
>> p <- p + geom_bar(aes(x=rownames(df), y=LAT), position="dodge",
>>     
> fill="green")
>   
>> p
>>     
df2=melt(id="idrow", df)
qplot(data=df2, x=idrow, y=value, 
fill=variable,stat="identity",geom="bar", position="dodge")

Ciao,
domenico
>
> but  the result graphics are overlapping.
>
> Thank for your help
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



More information about the R-help mailing list