weighted Bar plot

Share:

Description

A function to draw a weighted or unweighted barplot

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
bar.plot.wtd(x, y=NULL, z=NULL, w=NULL, data=NULL,
             vnames.x=NULL, vnames.y=NULL, vnames.z=NULL,
             btext=NULL, cutz=F, zperc=NULL,
             b=NULL, b2=0.5, v=NULL, h=NULL, gradient=FALSE,
             xlab="", ylab="", main="", ylim=NULL,
             yticks=NULL, col=NULL, tcol=NULL, bgcol=NULL, lcol=NULL,
             alpha=NULL, beside=TRUE, legendon="topright", wall=0,
             lhoriz=NULL, prozent=FALSE, ploc=0, form="r", border=TRUE,
             density=NULL, angle=NULL, density2=NULL, angle2=NULL, fill=NULL,
             lwd=1, lty=1, blwd=1, blty=1)

Arguments

x
  • a factor

  • a string with the name of the factor variable in the data.frame

  • a formula x~y or x~y+z

  • a table

y
  • second factor

  • a string with the name of second factor in the data.frame

z
  • third factor

  • a string with the name of thirds factor in the data.frame

w
  • a vector of weights

  • a string with the name of weight variable in the data.frame

data

a data.frame

vnames.x

a vector of character strings with labels for the levels of x

vnames.y

a vector of character strings with labels for the levels of y

vnames.z

a vector of character strings with labels for the levels of z

btext
  • logical asking whether to draw p-values from chisq test

  • a vector of character strings with test to draw over the bars

cutz

logical asking whether to use z variable to split bars or to calculate prozent of positive only.

zperc

a single keyword from:

  • "overall"

  • "rows"

  • "cols"

  • "zells"

What percentages from z should be calculated?

b

width of bars in [0, 1]

b2

depth of 3d bars in [0, 1]

v

the x-value(s) for vertical line(s).

h

the y-value(s) for horizontal line(s).

gradient

logical asking whether to draw a color gradient

xlab

a title for the x axis

ylab

a title for the y axis

main

an overall title for the plot

ylim

the y limits (y1, y2) of the plot

yticks

the number of ticks on the y axis

col

color for the bars representing levels of y

tcol

color of the text in whole plot

bgcol

the background color for plot dekoration

lcol

colors for the lines to shading bars, a vector is possible

alpha

a parameter in [0, 1] for semi-transparency of bars

beside

logical asking whether to draw bars beside or on top

legendon

a single keyword from:

  • "bottomright"

  • "bottom"

  • "bottomleft"

  • "left"

  • "topleft"

  • "top"

  • "topright"

  • "right"

  • "center"

  • "none"

This places the legend on the inside of the plot frame at the given location. To locate 2 legends you can give a vector of 2 keywords.

wall

a number between 0 and 6 for selection the dekoration style of the plot.

lhoriz

logical asking whether to draw legend horizontal

prozent

logical asking whether to draw percents on bars

ploc

Position of percents

  • 0: middle

  • 1, bottom

  • 2: over

  • 3: top

  • 4: under

form

a single keyword from:

  • 'r': Rects

  • 'c', 3D Rects

  • 'z': Zylinders (not working well)

border

logical asking whether to draw borders os bars

density

first density for shading lines, in lines per inch.

angle

first angle (in degrees) for the shading lines.

density2

second density for shading lines, in lines per inch.

angle2

second angle (in degrees) for the shading lines.

fill

fill color for bars if used density, because the col parameter will be used for color of the shading lines.

lwd

width for shading lines

lty

linetype for shading lines

blwd

width for bar-borders

blty

linetype for bar-borders

See Also

bar3d.ade

Examples

1
2
3
4
5
6
x<-rbinom(1000, 1, 0.75)
y<-rbinom(1000, 1, 0.30)
z<-rbinom(1000, 1, 0.50)
w<-abs(rnorm(1000))
bar.plot.wtd(x,y,z, w)
bar.plot.wtd(x,y,z, w, wall=4, form='c', main='Bar-Plot')