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:

screenshot


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -