Learn R Programming

biometrics (version 1.0.3)

barplotgr: Function for building a barplot for one or two factors

Description

The function creates a barplot of numeric vector by one or two factor.

Usage

barplotgr(
  yvar,
  factors,
  data = data,
  percentage = FALSE,
  errbar = !percentage,
  half.errbar = TRUE,
  conf.level = 0.95,
  xlab = NULL,
  ylab = NULL,
  main = NULL,
  names.arg = NULL,
  bar.col = "black",
  whisker = 0.015,
  args.errbar = NULL,
  legend = TRUE,
  legend.text = NULL,
  args.legend = NULL,
  legend.border = FALSE,
  box = TRUE,
  args.yaxis = NULL,
  mar = c(5, 4, 3, 2),
  ...
)

Value

The function returns the above described graph.

Arguments

yvar

The column having the variable to represent the height of the bars.

factors

A vector having the columns with the factors to be used in the resulting plot. Notice that the last listed factor, will be used in X-axis plot.

data

A data frame having the above described columns.

percentage

Logical value, set to FALSE.

errbar

Please set this option to FALSE.

half.errbar

Optional, default set to TRUE.

conf.level

Optional, a numeric value for the confidence interval, the default is 0.95.

xlab

Optional, as in the generic barplot function.

ylab

Optional, as in the generic barplot function.

main

Optional, as in the generic barplot function.

names.arg

Optional, as in the generic barplot function.

bar.col

Optional, as in the generic barplot function.

whisker

Optional, A numeric value, the default is 0.015.

args.errbar

Optional, as in the generic barplot function.

legend

Optional, as in the generic barplot function.

legend.text

Optional, as in the generic barplot function.

args.legend

Optional, as in the generic barplot function.

legend.border

Optional, as in the generic barplot function.

box

Optional, as in the generic barplot function.

args.yaxis

Optional, as in the generic barplot function.

mar

Optional, as in the generic barplot function.

...

list of columns to sort on

Author

Christian Salas-Eljatib

References

The present function was modified from a similar one available at https://github.com/mrxiaohe/R_Functions/blob/master/functions/bar

Examples

Run this code
data(standtabRauli2)
df <- standtabRauli2
head(df)
barplotgr(yvar = nha.cd, factors = c(bosque.id,cd), data = df,
errbar = FALSE, ylim=c(0, 640))

Run the code above in your browser using DataLab