as_string: as_string

as_stringR Documentation

as_string

Description

converts a character vector in a single string

Usage

as_string(txt, collapse = ", ", last = ", and ")

as_sum(txt)

as_obs(txt, name = "x", sorted = FALSE, ...)

as_fraction(val, latex = FALSE, sorted = FALSE, ...)

Arguments

txt

vector: (character) vector to merge

collapse

character: glue text between elements (default: ", ")

last

character: glue text between the two last elements (default: ", and ")

name

character: observation name (default: "x")

sorted

logical: sorted observations or not (default: FALSE)

...

further given from as_obs to as_string

val

numeric: values to convert into fractions

latex

logical use latex \frac{.}{.} or not (default: FALSE)

Value

a string

Examples

x <- runif(5)
y <- c(TRUE, FALSE, NA) 
as_string(x)
as_string(y)
# toString
as_string(as.character(x))
as_string(as.character(y))
#
as_obs(x)
as_obs(sort(x), sorted=TRUE)
#
x <- round(runif(5), 2)
as_fraction(x)
as_fraction(x, TRUE)
#
y <- round(runif(5), 2)
as_sum(x)

sigbertklinke/exams2moodle documentation built on July 6, 2023, 3:26 p.m.