0
votes

I have the following ggplot I was able to make in R:

x = 1:5  
y  = 6:10
df = data.frame(x,y)

ggplot(df, aes(x,y)) + labs(x = expression("1-dpi [2] Log"))

I'd like to use the 2 as a subscript but the expression function is not working for me for some reason. Would someone know how to troubleshoot? Thanks

Edit:

I was able to write the whole title out. my desired final title was: 1 dpi Log[2] Fold Change

My code for that is:

 expression(1~dpi~Log[2]~Fold~Change)
1

1 Answers

1
votes

Try this. I have used your data df. The key is setting all inside the expression() function like this:

library(ggplot2)
#Code
ggplot(df, aes(x,y)) + labs(x = expression(1-dpi[2]~Log))

Output:

enter image description here