[R] Substitution in expressions

Viechtbauer, Wolfgang (SP) wo||g@ng@v|echtb@uer @end|ng |rom m@@@tr|chtun|ver@|ty@n|
Tue Mar 26 14:27:48 CET 2019


Hi All,

I am trying to create a vector of expressions, where the elements in the expressions are contained in other vectors (i.e., they should be substituted). I made some attempts with substitute() and bquote(), but couldn't get this to work. My solution so far is:

base <- 1:5
expo <- c(2,2,3,3,4)
exvec <- as.expression(unname(mapply(function(x,y) bquote(.(x)^.(y)), base, expo)))

plot(NA, NA, xlim=c(0,6), ylim=c(0,2))
text(1:5, 1, exvec)

Any ideas how I could get this to work with substitute() and/or bquote()?

Best,
Wolfgang



More information about the R-help mailing list