draw_table: Helper function to draw table grobs.

Description Usage Arguments Details Acknowledgements Examples

View source: R/util_draw_table.R

Description

draw_table() Pre and post version: 2.0.0 gridExtra packages handle drawing tables differently. draw_table() determines the installed version of gridExtra and applies the appropriate syntax. If gridExtra version < 2.0.0 then it uses old gridExtra syntax to build table Grob(graphical object) else uses new syntax. draw_table()

Usage

1
draw_table(body, heading, ...)

Arguments

body

A dataframe. Table body.

heading

A string. Table title.

...

Further arguments to control the gtable.

Details

prints tables without rownames.

Acknowledgements

Thanks to Ryan Welch, https://github.com/welchr/LocusZoom/issues/16

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
library(gridExtra)

## Not run: 

# Table of iris values
iris_dframe <- head(iris)
title_iris_dframe <- paste("Table: Length and width measurements (cm) of sepals and petals,",
                            "for 50 flowers from 3 species of iris (setosa, versicolor,", 
                            "and virginica).\n", sep = " ")
# Wrap title text at column 60
title_iris_dframe <- sapply(strwrap(title_iris_dframe, width = 60, simplify = FALSE), 
                            paste, collapse = "\n")
# Draw table
table_influential_studies <- draw_table(body = iris_dframe, heading = title_iris_dframe)

# Table of mtcars values
mtcars_dframe <- head(mtcars)
title_mtcars_dframe <- paste("Table: Motor Trend US magazine (1974) automobile statistics", 
                             "for fuel consumption, \nautomobile design and performance.\n", 
                             sep = " ")
# Wrap title text at column 60
title_mtcars_dframe <- sapply(strwrap(title_mtcars_dframe, width = 60, simplify = FALSE), 
                              paste, collapse = "\n")
# Draw table
table_influential_studies <- draw_table(body = mtcars_dframe, heading = title_mtcars_dframe)

## End(Not run)

magosil86/getmstatistic documentation built on May 10, 2021, 9:47 a.m.