Commit 7520c6f5 authored by Gjalt-Jorn Peters's avatar Gjalt-Jorn Peters

minor bug

parent 1c1c5ab5
Pipeline #224867900 passed with stage
in 5 minutes and 41 seconds
......@@ -208,6 +208,8 @@ export(suspectParticipants)
export(uniDimColors)
export(varsToDiamondPlotDf)
export(vecTxt)
export(vecTxtB)
export(vecTxtM)
export(vecTxtQ)
export(zotero_construct_export_call)
export(zotero_download_and_export_items)
......
#' Wrapper for kableExtra for consistent `ufs` table styling
#'
#' @param x The dataframe to print
#' @param digits,format,escape,table.attr Defaults that are
#' passed to [knitr::kable()]
#' @param digits,format,escape,table.attr,lightable_options,html_font,full_width Defaults
#' that are passed to [knitr::kable()]
#' @param print Wther to print the table
#' @param viewer Whether to show the table in the viewer
#' @param kable_classic Whether to call `kable_classic`; otherwise,
#' `kable_styling` is called.
#' @param ... Additional arguments are passed to [knitr::kable()]
#'
#' @return The table, invisibly.
......@@ -17,25 +19,43 @@ kblXtra <- function(x,
escape = FALSE,
print=TRUE,
viewer = FALSE,
kable_classic = FALSE,
lightable_options = "striped",
html_font = "\"Arial Narrow\", \"Source Sans Pro\", sans-serif",
full_width = TRUE,
table.attr = "style='border:0px solid black !important;'",
...) {
oldKableViewOption <- getOption("kableExtra_view_html", NULL);
options(kableExtra_view_html = viewer);
res <-
kableExtra::kable_styling(
knitr::kable(
x,
digits = digits,
format = format,
escape = escape,
table.attr = table.attr,
...
),
bootstrap_options = "condensed"
kbl <-
knitr::kable(
x,
digits = digits,
format = format,
escape = escape,
table.attr = table.attr,
...
);
if (kable_classic) {
res <-
kableExtra::kable_classic(
kbl,
lightable_options = lightable_options,
html_font = html_font,
full_width = full_width
);
} else {
res <-
kableExtra::kable_styling(
kbl,
bootstrap_options = "condensed",
html_font = html_font,
full_width = full_width
);
}
if (print || viewer) {
print(res);
}
......
......@@ -17,7 +17,7 @@ modus <- function(vector) {
### Store the names of the most common category (or categories)
categoryVector <- names(freqs[freqs==highestFreq]);
### Now, we need to supply this back in the same class as the original.
if (originalClass=="factor") {
if ("factor" %in% originalClass) {
categoryVector <- as.factor(categoryVector);
}
else {
......
#' Easily parse a vector into a character value
#'
#' `vecTxtQ`, `vecTxtB`, and `vecTxtM` and are convenience functions
#' with default quotes that can be useful when working in R Markdown
#' documents.
#'
#' @param vector The vector to process.
#' @param delimiter,firstDelimiter,lastDelimiter The delimiters
#' to use for respectively the middle, first
......@@ -76,3 +80,15 @@ vecTxt <- function(vector, delimiter = ", ", useQuote = "",
vecTxtQ <- function(vector, useQuote = "'", ...) {
return(vecTxt(vector, useQuote = useQuote, ...));
}
#'@rdname vecTxt
#'@export
vecTxtB <- function(vector, useQuote = "`", ...) {
return(vecTxt(vector, useQuote = useQuote, ...));
}
#'@rdname vecTxt
#'@export
vecTxtM <- function(vector, useQuote = "$", ...) {
return(vecTxt(vector, useQuote = useQuote, ...));
}
......@@ -11,6 +11,10 @@ kblXtra(
escape = FALSE,
print = TRUE,
viewer = FALSE,
kable_classic = FALSE,
lightable_options = "striped",
html_font = "\\"Arial Narrow\\", \\"Source Sans Pro\\", sans-serif",
full_width = TRUE,
table.attr = "style='border:0px solid black !important;'",
...
)
......@@ -18,13 +22,16 @@ kblXtra(
\arguments{
\item{x}{The dataframe to print}
\item{digits, format, escape, table.attr}{Defaults that are
passed to \code{\link[knitr:kable]{knitr::kable()}}}
\item{digits, format, escape, table.attr, lightable_options, html_font, full_width}{Defaults
that are passed to \code{\link[knitr:kable]{knitr::kable()}}}
\item{print}{Wther to print the table}
\item{viewer}{Whether to show the table in the viewer}
\item{kable_classic}{Whether to call \code{kable_classic}; otherwise,
\code{kable_styling} is called.}
\item{...}{Additional arguments are passed to \code{\link[knitr:kable]{knitr::kable()}}}
}
\value{
......
......@@ -3,6 +3,8 @@
\name{vecTxt}
\alias{vecTxt}
\alias{vecTxtQ}
\alias{vecTxtB}
\alias{vecTxtM}
\title{Easily parse a vector into a character value}
\usage{
vecTxt(
......@@ -17,6 +19,10 @@ vecTxt(
)
vecTxtQ(vector, useQuote = "'", ...)
vecTxtB(vector, useQuote = "`", ...)
vecTxtM(vector, useQuote = "$", ...)
}
\arguments{
\item{vector}{The vector to process.}
......@@ -47,7 +53,9 @@ last delimiter (\code{FALSE})?}
A character vector of length 1.
}
\description{
Easily parse a vector into a character value
\code{vecTxtQ}, \code{vecTxtB}, and \code{vecTxtM} and are convenience functions
with default quotes that can be useful when working in R Markdown
documents.
}
\examples{
vecTxtQ(names(mtcars));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment