Permalink
Browse files

started to add examples as per cran comments

  • Loading branch information...
RobinL committed Oct 24, 2017
1 parent 026b973 commit a78bf40dbd472f741b837a2e00f7489af870dd16
Showing with 63 additions and 0 deletions.
  1. +8 −0 R/body.R
  2. +6 −0 R/title.R
  3. +9 −0 R/top_headers.R
  4. +14 −0 inst/extdata/example_crosstab.csv
  5. +9 −0 man/add_body.Rd
  6. +7 −0 man/add_title.Rd
  7. +10 −0 man/add_top_headers.Rd
View
@@ -30,6 +30,14 @@ body_initialise <- function(tab) {
#' @param fill_non_values_with Manually specify a list of strings that will replace non numbers types NA, NaN, Inf and -Inf. e.g. list(na = '*', nan = '', inf = '-', neg_inf = '--'). Note: NaNs are not treated as NAs.
#'
#' @export
#' @examples
#' crosstab <- read.csv(system.file("extdata", "example_crosstab.csv", package="xltabr"))
#' tab <- initialise()
#'
#' # Note you could also use xltabr::auto_detect_left_headers
#' colnames <- c("drive", "age")
#' lh_styles <- "left_header"
#' tab <- add_body(tab, crosstab, left_header_colnames = colnames)
add_body <-
function(tab,
df,
View
@@ -17,6 +17,12 @@ title_initialise <- function(tab) {
#' @param title_text A character vector. Each element is a row of the title
#' @param title_style_names A character vector. Each elemment is a style_name
#' @export
#' @examples
#' crosstab <- read.csv(system.file("extdata", "example_crosstab.csv", package="xltabr"))
#' tab <- initialise()
#' title_text <- c("Main title on first row", "subtitle on second row")
#' title_style_names <- c("title", "subtitle")
#' tab <- add_title(tab, title_text, title_style_names)
add_title <- function(tab, title_text, title_style_names = NULL) {
if (is.null(title_style_names)) {
View
@@ -24,6 +24,15 @@ top_headers_initialise <- function(tab) {
#' @param col_style_names A character vector, with and element for each column of the top header. Each element is a style name. Col styles in inherit from row_styles.
#'
#' @export
#' @examples
#' crosstab <- read.csv(system.file("extdata", "example_crosstab.csv", package="xltabr"))
#' tab <- initialise()
#'
#' top_headers_row_1 <- c("", "", "Car type", "Car type", "Car type")
#' top_headers_row_2 <- c("Drive", "Age", "Sedan", "Sport", "Supermini")
#' top_headers <- list(top_headers_row_1, top_headers_row_2)
#'
#' tab <- add_top_headers(tab, top_headers)
add_top_headers <- function(tab, top_headers, col_style_names="", row_style_names="body|top_header_1") {
# Check types and assign the data to top_headers_list. Each row is an element in the list
@@ -0,0 +1,14 @@
drive,age,Sedan,Sport,Supermini
(all),(all),-2.8416683023460796,16.73033823058852,13.713586267810289
Internal combustion,(all),-9.543277884105652,11.020000396242049,-9.959797664580321
Internal combustion,Brand new,-8.67120092908686,0.08939142352793625,-4.848979261723276
Internal combustion,5 years +,-4.8821649316642075,-0.6271567409031884,-7.489549336643794
Internal combustion,0-5 years,4.010087976645415,11.5577657136173,2.378730933786748
Hybrid,(all),14.347425700502269,16.634997026788426,27.327583927314382
Hybrid,Brand new,8.780084519829284,13.102760281604654,4.486288891494578
Hybrid,5 years +,6.612231667026279,-8.862746504700954,16.409699702418024
Hybrid,0-5 years,-1.0448904863532948,12.394983249884726,6.431595333401783
Electric,(all),-7.6458161187426965,-10.924659192441958,-3.654199994923773
Electric,Brand new,-1.8732507244930172,7.151712044206935,-9.722967591541446
Electric,5 years +,0.64603271862817,-7.884957555318913,1.076317412959917
Electric,0-5 years,-6.418598112877849,-10.19141368132998,4.992450183657755
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit a78bf40

Please sign in to comment.