I'm trying to have the same mathematical formula for both a plot (ggplot2::ggplot) and markdown table(knitr::kable) in R. Below is how I would add a formula to a plot.
# Basic R scatter plot with "wt" replaced by a mathematical expression for the x-axis-label
g1 <- ggplot2::ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point() + xlab(expression(beta[0]))
g1
xl <- g1$labels$x
xl
Can I auto-convert/parse the xl "beta[0]" expression to markdown "$$\beta_0$$"? ... e.g. for only a manual conversion table below
xl <- "$$\\beta_0$$"
knitr::kable(cbind(var = xl,mean = mean(g1$data$wt)))
Or is their an easier way to use the formula from a ggplot in a markdown table?