[R] graph: horizontal bar reflecting number of data

Jim Lemon drjimlemon at gmail.com
Wed Jul 13 13:58:05 CEST 2016


Hi Tagmarie,
This might help:

datframe$numberdata<-as.numeric(as.character(datframe$numberdat))
library(plotrix)
barcol<-color.scale(datframe$numberdat,extremes=c("black","white"))
barplot(matrix(datframe$numberdat,nrow=2,byrow=TRUE),
 beside=TRUE, horiz=TRUE,names.arg=paste("Week",1:3),
 col=matrix(barcol,nrow=2,byrow=TRUE))

Jim


On Wed, Jul 13, 2016 at 5:59 PM, Dagmar <Ramgad82 at gmx.net> wrote:
> Dear all,
>
> I hope someone can help with my problem:
>
> I have a dataframe like this:
>
> datframe <- data.frame(Name=c("Kati","Kati","Kati","Leon","Leon","Leon" ),
> week =c("1","2", "3", "1","2", "3"), numberdata =c("5","12", "1", "6","2",
> "5"))
> datframe
>
> I want to create a graph like the attached one (jpg). I can't bring the bars
> to  line up by week... desperating.
>
> (in case you don't see the jpg: I want a horizontal bar which reflects the
> number of data per week by the colour of the shading).
>
> Can anyone help?
>
> Tagmarie
>
>
>
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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