I'm trying to use paste
in a for loop
in R
to create new expressions
for a ggplot
. I currently have:
x_axis_label <- list()
for (i in seq_len(4)) {
x_axis_label[[i]] <- expression(paste("10"^as.character(i)))
}
but this returns:
[[1]]
expression(paste("10"^as.character(i)))
[[2]]
expression(paste("10"^as.character(i)))
[[3]]
expression(paste("10"^as.character(i)))
[[4]]
expression(paste("10"^as.character(i)))
Is it possible to use a for loop
and paste a value within an expression
in R
?
EDIT: I would like to have a vector similar to the below:
x_axis_label <- c(expression(paste("10"^"2")),
expression(paste("10"^"3")),
expression(paste("10"^"4")))
expression(paste("10"^"2"), paste("10"^"3"), paste("10"^"4"))
Thanks.