title: How to add main title and manipulating axis labels in ggplot2 in Rstudio
body: <p>I am new to R and I am using Rstudio.</p>
  
  <p>I have a ggplot2 R script for drawing a bar plot (<a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4864582/figure/iew014-F3/" rel="nofollow noreferrer">something same as this</a>) that I have created it by <a href="https://stackoverflow.com/questions/39563029/how-to-draw-clusters-of-orthologous-groups-cog-barplot-using-ggplot2-in-r/39563138?noredirect=1#comment66473260_39563138">others help</a> but it has two errors that seems super simple but I can not solve them:</p>
  
  <p><strong>1)</strong> in the <strong>x axis label</strong> it must be the <strong>Function Class</strong>, but it is <strong>FunctionClass</strong>(without space). and when I add space, it shows this error -> :<strong>Error</strong>: unexpected symbol in "p &lt;- ggplot(data=dat, aes(x=Function Class"  </p>
  
  <p><strong>2)</strong> I can not add the Main Title to the plot</p>
  
  <p>I have this line "p + guides (fill = guide_legend(ncol = 1))" for showing the legend in one column (and I need it in my script). </p>
  
  <p>When I insert the script "p + <strong>ggtitle</strong> ("COG Function Classification of Consensus Sequences")+" before that, there is no main title. when I put this script after that, there is a title but the one column legend transform to an ugly two column legend! and the X axis naming is still exist. (I have even used opt(), theme() and ..., but each of them show another errors, so <strong>it is not a duplicated question</strong> and it is my case issue). </p>
  
  <p>Help me and if it is possible, <strong>please</strong> add the appropriate lines in my script or mention the scripts and the position that I have to insert them because it seems that the please of each command has some effect on the whole program.</p>
  
  <p>Thank you in advance and <strong>this is my script</strong> :</p>
  
  <pre><code>    dat &lt;- data.frame(
    FunctionClass = factor(c("A", "B", "C", "D", "E", "F", "G", "H", "I",     "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "Y", "Z"), levels=c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "Y", "Z")),
    legend = c("A: RNA processing and modification", "B: Chromatin structure and dynamics", "C: Energy production and conversion", "D: Cell cycle control, cell division, chromosome partitioning", "E: Amino acid transport and metabolism", "F: Nucleotide transport and metabolism", "G: Carbohydrate transport and metabolism", "H: Coenzyme transport and metabolism", "I: Lipid transport and metabolism", "J: Translation, ribosomal structure and biogenesis", "K: Transcription", "L: Replication, recombination and repair", "M: Cell wall/membrane/envelope biogenesis", "N: Cell motility", "O: Posttranslational modification, protein turnover, chaperones", "P: Inorganic ion transport and metabolism", "Q: Secondary metabolites biosynthesis, transport and catabolism", "R: General function prediction only", "S: Function unknown", "T: Signal transduction mechanisms", "U: Intracellular trafficking, secretion, and vesicular transport", "V: Defense mechanisms", "W: Extracellular structures", "Y: Nuclear structure", "Z: Cytoskeleton"),
    Frequency=c(360,391,897,1558,1168,448,1030,536,732,1292,2221,2098,789,117,1744,732,437,5162,1251,2191,603,216,2,14,739)
  )
  
  library(ggplot2)
  
  p &lt;- ggplot(data=dat, aes(x=FunctionClass, y=Frequency, fill=legend))+
  
  geom_bar(stat="identity", position=position_dodge(), colour="seashell")
  
  p + guides (fill = guide_legend(ncol = 1))
  </code></pre>