Giacomo Prodi
2008-Jun-03 16:56 UTC
[R] problems on plotting adjacent bars with barplot. Help request, please
hi ladyes and gentlemans of the R comunity.
i have the following graphical issue:
# say y is a matrix or a dataframe with
dim(51,nrow=17),hence 3 columns;
l<-51
# now the 3 colums represents 3 different aspects of
my continuous variable (3 factors),plotted against a
categorical one;
n<-levels(factor(x))
# i want to plot those 3 factors adjacently using the
barplot(), and possibly show error bars as well;
err<-rep(1.2,17)
this is the function that i unsuccesfully wrote to do
this:
adj.bars<-function(y,e,n,l){
both<-numeric(l)
both[1:l%%2==1]<-y[,1]
both[1:l%%2!=c(0,1)]<-y[,2]
both[1:l%%2==0]<-y[,3]
labels<-character(l)
labels[1:l%%2==1]<-n
xv<-barplot(both,col=rep(c(1,2,3),17),
ylim=c(0,max(y)+e[1]),names=labels)
up<-x[,1]+e
down<-x[,1]-e
arrows(xv,up,xv,down,code=3,angle=90,length=0.025)
up2<-x[,2]+e
down2<-x[,2]-e
arrows(xv,up,xv,down,code=3,angle=90,length=0.025)
up3<-x[,3]+e
down3<-x[,3]-e
arrows(xv,up,xv,down,code=3,angle=90,length=0.025)
}
i guess the "both" instruction is fake 'cause the plot
looks really wrong.
i have also tried this other one.
rm(l)
l<-17
adj.bars<-function(y,e,n,l){
both<-rep(c(1,1.5,2),l)
both[1:l%%2==1]<-y[,1]
both[1:l%%2==1.5]<-y[,2]
both[1:l%%2==0]<-y[,3]
...........
i thank you all for the attention, and i'll be
grateful if someone had simple tip to all this.
FEDERICO, undergraduate student in Insubria University
Varese, Italy.
___________________________________
http://www.ymailblogit.com/blog/
Possibly Parallel Threads
- hello! i need help for a specific graphic issue
- 9 commits - configure.ac test/custom test/Makefile.am test/swfdec_test_initialize.as test/swfdec_test_initialize.h test/swfdec_test_test.c test/trace
- 59 commits - libswfdec-gtk/swfdec_gtk_widget.c libswfdec/swfdec_as_object.c libswfdec/swfdec_as_object.h libswfdec/swfdec_button.c libswfdec/swfdec_button.h libswfdec/swfdec_button_movie.c libswfdec/swfdec_button_movie.h libswfdec/swfdec_event.c
- How to remove autocorrelation from a time series?
- wine rc2 regression : Silver
