Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
9
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Open sidebar
R-packages
ufs
Commits
7520c6f5
Commit
7520c6f5
authored
Dec 03, 2020
by
Gjalt-Jorn Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor bug
parent
1c1c5ab5
Pipeline
#224867900
passed with stage
in 5 minutes and 41 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
71 additions
and
18 deletions
+71
-18
NAMESPACE
NAMESPACE
+2
-0
R/kblXtra.R
R/kblXtra.R
+34
-14
R/modus.R
R/modus.R
+1
-1
R/vecTxt.R
R/vecTxt.R
+16
-0
man/kblXtra.Rd
man/kblXtra.Rd
+9
-2
man/vecTxt.Rd
man/vecTxt.Rd
+9
-1
No files found.
NAMESPACE
View file @
7520c6f5
...
...
@@ -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)
...
...
R/kblXtra.R
View file @
7520c6f5
#' 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
);
}
...
...
R/modus.R
View file @
7520c6f5
...
...
@@ -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
{
...
...
R/vecTxt.R
View file @
7520c6f5
#' 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
,
...
));
}
man/kblXtra.Rd
View file @
7520c6f5
...
...
@@ -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{
...
...
man/vecTxt.Rd
View file @
7520c6f5
...
...
@@ -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));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment