Displaying values from a character vector as italic labels in boxplot in R -
i want use character vector boxplot names, how can these displayed italic?
# data x <- rnorm(1000) # want this: labels <- c(expression(italic("one"), italic("two"))) labels boxplot(split(x, cut(x,breaks = c(-inf, 0, inf))), names = labels)
but using character vector, such
snames <- c("one", "two")
i've tried bquote()
, expression()
...
labels <- bquote(expression(italic(.(snames)))) labels # length 1, not 2
... , sapply()
labels <- sapply(snames, function(x) bquote(expression(italic(.(x))))) labels boxplot(split(x, cut(x,breaks = c(-inf, 0, inf))), names = labels)
but doesn't seem interpreted expression.
thanks help.
create following function , use shown:
make.italic <- function(x) as.expression(lapply(x, function(y) bquote(italic(.(y))))) boxplot(split(x, cut(x,breaks = c(-inf, 0, inf))), names = make.italic(snames))
which gives:
Comments
Post a Comment