title: Formatting text labels of categorical variables
body: <p>Suppose that there is a dataframe which contains the following data:</p>
  
  <pre><code>Freq=c(0.15,0.25,0.6)
  x=as.factor(c("Some long long long long text", "Another long long long long text", "But, this is really long long long long long text" ))
  df&lt;-data.frame(x=x, Freq=Freq)
  </code></pre>
  
  <p>And from this dataframe I would like to make a particular plot such as this one:</p>
  
  <pre><code>ggplot(df, aes(x=x, y=Freq)) + 
    geom_bar(stat="Identity", fill="dodgerblue3", width=.7) + 
    geom_text(aes(y = Freq, label = scales::percent(Freq), vjust = -0.5))+
    scale_y_continuous(labels=scales::percent, name ="", limits = c(0,0.7), expand = c(0,0))+
    scale_x_discrete(labels = levels(df$x), name="")
  </code></pre>
  
  <p>As you can see, the problem is that the labels of my discrete variable x, because are too long, do not appear nicely. </p>
  
  <p><a href="https://i.stack.imgur.com/XrFqQ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XrFqQ.jpg" alt="enter image description here"></a></p>
  
  <p>A very ad hoc solution that I could think, was to do this: </p>
  
  <pre><code>ggplot(df, aes(x=x, y=Freq)) + 
        geom_bar(stat="Identity", fill="dodgerblue3", width=.7) + 
        geom_text(aes(y = Freq, label = scales::percent(Freq), vjust = -0.5))+
        scale_y_continuous(labels=scales::percent, name ="", limits = c(0,0.7), expand = c(0,0))+
        scale_x_discrete(labels = c("Some long \n long long \n long text", "Another long \n long long \n long text", "But, this is \n really long long \n long long \n long text"), name="")
  </code></pre>
  
  <p>Which gives me this figure: </p>
  
  <p><a href="https://i.stack.imgur.com/Ycnoy.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ycnoy.jpg" alt="enter image description here"></a></p>
  
  <p>So, my question is whether there is another solution which does not require a manual intervention in the labels as I did. </p>