as_string {exams.forge}R Documentation

Vector to String Conversion

Description

Converts a character vector into 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, ...)

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

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

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

Arguments

txt

vector: (character) vector to merge

collapse

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

last

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

name

character: observation name (default: "x")

sorted

logical: sorted or not sorted observations (default: FALSE)

...

further parameters (given from as_obs to as_string)

val

numeric: values to convert into fractions

latex

logical use of 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)

[Package exams.forge version 1.0.10 Index]