Last chance! 50% off unlimited learning
Sale ends in
Print character strings without quotes.
noquote(obj, right = FALSE)# S3 method for noquote
print(x, quote = FALSE, right = FALSE, …)
# S3 method for noquote
c(…, recursive = FALSE)
any R object, typically a vector of
character
strings.
optional logical
eventually to be passed to
print()
, used by print.default()
, indicating
whether or not strings should be right aligned.
an object of class "noquote"
.
further options passed to next methods, such as print
.
for compatibility with the generic c
function.
noquote
returns its argument as an object of class
"noquote"
. There is a method for c()
and subscript
method ("[.noquote"
) which ensures that the class is not lost
by subsetting. The print method (print.noquote
) prints
character strings without quotes ("\dots"
).
If right
is specified in a call print(x, right=*)
, it
takes precedence over a possible right
setting of x
,
e.g., created by x <- noquote(*, right=TRUE)
.
These functions exist both as utilities and as an example of using (S3)
class
and object orientation.
# NOT RUN {
letters
nql <- noquote(letters)
nql
nql[1:4] <- "oh"
nql[1:12]
cmp.logical <- function(log.v)
{
## Purpose: compact printing of logicals
log.v <- as.logical(log.v)
noquote(if(length(log.v) == 0)"()" else c(".","|")[1 + log.v])
}
cmp.logical(stats::runif(20) > 0.8)
chmat <- as.matrix(format(stackloss)) # a "typical" character matrix
## noquote(*, right=TRUE) so it prints exactly like a data frame
chmat <- noquote(chmat, right = TRUE)
chmat
# }
# NOT RUN {
<!-- %dont -->
# }
Run the code above in your browser using DataLab