Learn R Programming

tern (version 0.9.8)

df2gg: Convert data.frame object to ggplot object

Description

[Experimental]

Given a data.frame object, performs basic conversion to a ggplot2::ggplot() object built using functions from the ggplot2 package.

Usage

df2gg(
  df,
  colwidths = NULL,
  font_size = 10,
  col_labels = TRUE,
  col_lab_fontface = "bold",
  hline = TRUE,
  bg_fill = NULL
)

Value

A ggplot object.

Arguments

df

(data.frame)
a data frame.

colwidths

(numeric or NULL)
a vector of column widths. Each element's position in colwidths corresponds to the column of df in the same position. If NULL, column widths are calculated according to maximum number of characters per column.

font_size

(numeric(1))
font size.

col_labels

(flag)
whether the column names (labels) of df should be used as the first row of the output table.

col_lab_fontface

(string)
font face to apply to the first row (of column labels if col_labels = TRUE). Defaults to "bold".

hline

(flag)
whether a horizontal line should be printed below the first row of the table.

bg_fill

(string)
table background fill color.

Examples

Run this code
if (FALSE) {
df2gg(head(iris, 5))

df2gg(head(iris, 5), font_size = 15, colwidths = c(1, 1, 1, 1, 1))
}

Run the code above in your browser using DataLab