nt_barplot: Barplot

View source: R/barplot.R

nt_barplotR Documentation

Barplot

Description

Plot barplot for several variables.

Usage

nt_barplot(
  data,
  group = NULL,
  labels = NULL,
  ylab = "Percent (%)",
  save = FALSE,
  fig.height = 5,
  fig.width = 5,
  std_fun = std_barplot,
  std_fun_group = std_barplot_group,
  ...
)

Arguments

data

a data frame with the variables.

group

a character value indicating the group variable.

labels

a list of labels with components given by their variable names.

ylab

a character value specifying the y axis label.

save

a logical value indicating whether the output should be saved as a jpeg file.

fig.height

a numeric value indicating the height (in) of the file.

fig.width

a numeric value indicating the width (in) of the file.

std_fun

a function to plot a barplot when group = NULL. It must follow the same structure of std_barplot.

std_fun_group

a function to plot a dotplot when group is provided. It must follow the same structure of std_barplot_group.

...

additional input arguments that may be used when creating your own function.

Details

The functions std_barplot and std_barplot_group are stardard functions that can be modified by the user in order to customize the barplots a prior. The plots also can be modified a posterior as a regular ggplot object. See geom_bar, std_barplot and std_barplot_group.

Value

a list of ggplot objects with each item named by the column names from var.

Examples

library(dplyr)
data(iris)

vars <- iris |>
transmute(Species = Species,
         Sepal.Length.C = ifelse(Sepal.Length > 5, "> 5", "<= 5"),
         Sepal.Width.C = ifelse(Sepal.Width > 3.5, "> 3.5", "<= 3.5"))
vars |> nt_barplot(group = Species)


dnzmarcio/ntimes documentation built on Jan. 4, 2024, 2:23 p.m.