title: barplot graph not displaying properly in sweave & knitr generated pdf
body: <p>I do not know if this is a bug in knitr? or am I doing anything wrong. </p>
  
  <p>I wanted to generate a barplot from a matrix generated from this vector (1):</p>
  
  <pre><code>14.556962,  8.227848, 51.898734, 19.303797,  6.012658, 10.126582, 28.797468, 35.759494, 14.873418, 10.443038, 11.708861, 20.253165, 38.924051, 22.468354,  6.645570, 11.501597, 23.003195, 36.741214, 17.891374, 10.862620, 13.870968, 33.548387, 34.516129, 13.548387, 4.516129
  </code></pre>
  
  <p>This is the code for the barplot (it is a stacked barplot) summing to 100 % </p>
  
  <pre><code>&lt;&lt;label=figealb1,fig=TRUE,height=3.8,results=hide,echo=FALSE&gt;&gt;=
  barplot(matrix(as.vector(as.numeric(enzymy$C.ALB[,1:5])),ncol=5))
  @
  </code></pre>
  
  <p>This vector (1) generally is what is printed when i call the <code>enzymy$C.ALB[,1:5]</code> </p>
  
  <p>Now when I generate the pdf using the above code i would get a stacked barplot without the first column (4 columns total) !!!!</p>
  
  <p>But if I generate it with copy pasing the results of the <code>enzymy$C.ALB[,1:5]</code> variable like this:</p>
  
  <pre><code>&lt;&lt;label=figealb,fig=TRUE,height=3.8,results=hide,echo=FALSE&gt;&gt;=
  barplot(matrix(c(14.556962,  8.227848, 51.898734, 19.303797,  6.012658, 10.126582, 28.797468, 35.759494, 14.873418, 10.443038, 11.708861, 20.253165, 38.924051, 22.468354,  6.645570, 11.501597, 23.003195, 36.741214, 17.891374, 10.862620, 13.870968, 33.548387, 34.516129, 13.548387, 4.516129),ncol=5))
  @
  </code></pre>
  
  <p>...then the plot is generated as it should - with five columns. </p>
  
  <p>What could to be the problem?</p>
  
  <p><code>enzymy</code> is a list of data frames. </p>
  
  <pre><code>str(enzymy)
  List of 14
   $ C.ALB  : num [1:5, 1:19] 14.56 8.23 51.9 19.3 6.01 ...
    ..- attr(*, "dimnames")=List of 2
    .. ..$ : NULL
    .. ..$ : chr [1:19] "E1" "E2" "E3" "E4" ...
  </code></pre>
  
  <p>Exporting to an image or pdf through Rstudio works fine so it is only kniter/Swaeve problem.</p>
  
  <p>Here is the image of a knitr/sweave pdf-generated plot </p>
  
  <p><img src="https://i.stack.imgur.com/i3cmh.jpg" alt="corrupted plot"></p>
  
  <p>Could anyone help?! Thanks</p>
  
  <p>I am trying to make it REPRODUCIBLE as requested, so here it is:
  1. I am using pdflatex,
  RStudio Version 0.98.490, </p>
  
  <pre><code>&gt; R.Version()
  $platform
  "x86_64-pc-linux-gnu"
  
  $version.string
  "R version 3.1.1 (2014-07-10)"
  
  $nickname
  "Sock it to Me"
  </code></pre>
  
  <p>You can download the database here: (please edit the path in the code below)</p>
  
  <p><a href="https://github.com/wolass/R/blob/master/colonies.csv" rel="nofollow noreferrer">https://github.com/wolass/R/blob/master/colonies.csv</a></p>
  
  <p>now load it and prepare:</p>
  
  <pre><code>\documentclass{book}
  \begin{document}
  \SweaveOpts{concordance=TRUE} 
  
  &lt;&lt;&gt;&gt;=
  colonies &lt;- read.csv("path/colonies.csv",colClasses="character")
  colonies &lt;- colonies[,-3]
  colonies &lt;- colonies[,-5]
  col_names &lt;- c(1:3,5:35)
  colonies[,col_names] &lt;- lapply(colonies[,col_names] , factor)
  colonies$Wiek.1 &lt;- as.numeric(colonies$Wiek.1)
  
  
  enzymy &lt;- lapply(split(colonies, colonies$Wynik), function(x){
            foo&lt;- lapply(lapply(lapply(x[,17:35],summary),function(x){x[2:6]}),prop.table)
            mat &lt;- matrix(unlist(foo)*100,byrow=F,nrow=5)
            colnames(mat) &lt;- c("E1","E2","E3","E4","E5","E6","E7","E8","E9","E10","E11","E12","E13","E14","E15","E16","E17","E18","E19")
    return(mat)
  })
  @
  
  This graph is what it supposed to look like:
  
  &lt;&lt;label=figealb,fig=TRUE,height=3.8,results=hide,echo=FALSE&gt;&gt;=
  barplot(matrix(c(14.556962,  8.227848, 51.898734, 19.303797,  6.012658, 10.126582, 28.797468, 35.759494, 14.873418, 10.443038, 11.708861, 20.253165, 38.924051, 22.468354,  6.645570, 11.501597, 23.003195, 36.741214, 17.891374, 10.862620, 13.870968, 33.548387, 34.516129, 13.548387, 4.516129),ncol=5))
  @
  
  This is how it looks like unfortunately:
  
  &lt;&lt;label=figealb1,fig=TRUE,height=3.8,results=hide,echo=FALSE&gt;&gt;=
  barplot(matrix(as.vector(as.numeric(enzymy$C.ALB[,1:5])),ncol=5))
  @
  
  \end{document}
  </code></pre>