Answers.Body: <p>This isn't a bioinformatics question, but it's quicker to answer than to close.</p>
  
  <pre><code>df1 &lt;- read.table(text = "
  AA 4
  AA 6
  BB 6
  AB 5
  BA 4
  AA 3
  NN 2
  AN 6
  NN 5
  AN 4
  NA 3
  BB 6
  BN 5
  NB 1
  BN 7", na.strings = "")
  
  library(ggplot2)
  
  ggplot(df1, aes(x = V1, y = V2)) +
    geom_bar(stat = "identity")
  </code></pre>
  
  <p><a href="https://i.sstatic.net/2srXF.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/2srXF.jpg" alt="enter image description here"></a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-23T14:03:17.710Z
Answers.Text: You can use `geom_col()` instead of `geom_bar(stat = 'identity')`.
Answers.UserDisplayName: Konrad Rudolph
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-23T14:05:00.793Z
Answers.Text: @KonradRudolph Good to know, I don't think that function was around when I started with ggplot2.
Answers.UserDisplayName: Devon Ryan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-23T14:05:45.787Z
Answers.Text: Yes, I think it was added somewhat recently (precisely because `geom_bar` has such a wonky default).
Answers.UserDisplayName: Konrad Rudolph
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-23T16:06:06.913Z
Answers.Text: "This isn't a bioinformatics question, but it's quicker to answer than to close." Nevertheless we can close it.
Answers.UserDisplayName: llrs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-23T13:31:08.680Z
Answers.LastActivityDate: 2018-01-23T13:56:01.013Z
Answers.LastEditDate: 2018-01-23T13:56:01.013Z
Answers.UserDisplayName: Devon Ryan
Body: <p>I have a basic ggplot2 R question. I have a dataframe in which data looks like this:</p>
  
  <pre><code>AA 4
  AA 6
  BB 6
  AB 5
  BA 4
  AA 3
  NN 2
  AN 6
  NN 5
  AN 4
  NA 3
  BB 6
  BN 5
  NB 1
  BN 7
  </code></pre>
  
  <p>The file is of multiple lines. I want to make a histogram using gplot2 that will plot the 9 kinds of variables AA,BB,AB,BA,AN,BN,NN,NB,NA on the x-axis and the sum of it's corresponding values in the next column on the y-axis. </p>
  
  <p>So for example, here the y-values should be </p>
  
  <pre><code>AA= 13
  BB= 12
  AB= 5
  BA= 4
  NN= 7
  AN= 10
  NA= 3
  BN= 12
  NB= 1
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-01-23T16:05:20.440Z
Comments.Text: I'm voting to close this question as off-topic because it is not about bioinformatics
Comments.UserDisplayName: llrs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-01-23T16:23:00.510Z
Comments.Text: Sorry for the inconvenience. Should I delete the question?
Comments.UserDisplayName: rishi
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-01-23T16:24:43.413Z
Comments.Text: No, it might help other people. But please search the internet before posting questions. (Also have a look at StackOverflow, many times it has been already asked and answered). Finding solutions to own's problem is a good skill to have.
Comments.UserDisplayName: llrs
Tags: <r><visualization><ggplot2>
Title: Histogram of different classes of variables in one column
ThreadText: # Histogram of different classes of variables in one column
  
  (Asked by: username_0 on 2018-01-23)
  
  I have a basic ggplot2 R question. I have a dataframe in which data looks like this:
  
  ```
  AA 4
  AA 6
  BB 6
  AB 5
  BA 4
  AA 3
  NN 2
  AN 6
  NN 5
  AN 4
  NA 3
  BB 6
  BN 5
  NB 1
  BN 7
  
  ```
  
  The file is of multiple lines. I want to make a histogram using gplot2 that will plot the 9 kinds of variables AA,BB,AB,BA,AN,BN,NN,NB,NA on the x-axis and the sum of it's corresponding values in the next column on the y-axis.
  
  So for example, here the y-values should be
  
  ```
  AA= 13
  BB= 12
  AB= 5
  BA= 4
  NN= 7
  AN= 10
  NA= 3
  BN= 12
  NB= 1
  
  ```
  
  **Tags:** r, visualization, ggplot2
  
  > **Comments:**
  > **username_1**: I'm voting to close this question as off-topic because it is not about bioinformatics  
  > **username_0**: Sorry for the inconvenience. Should I delete the question?  
  > **username_1**: No, it might help other people. But please search the internet before posting questions. (Also have a look at StackOverflow, many times it has been already asked and answered). Finding solutions to own's problem is a good skill to have.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2018-01-23. Score: 2 | Accepted answer
  
  This isn't a bioinformatics question, but it's quicker to answer than to close.
  
  ```
  df1 <- read.table(text = "
  AA 4
  AA 6
  BB 6
  AB 5
  BA 4
  AA 3
  NN 2
  AN 6
  NN 5
  AN 4
  NA 3
  BB 6
  BN 5
  NB 1
  BN 7", na.strings = "")
  
  library(ggplot2)
  
  ggplot(df1, aes(x = V1, y = V2)) +
    geom_bar(stat = "identity")
  
  ```
  
  [![enter image description here](https://i.sstatic.net/2srXF.jpg)](https://i.sstatic.net/2srXF.jpg)
  
  > **Comments:**
  > **username_3**: You can use `geom_col()` instead of `geom_bar(stat = 'identity')`.  
  > **username_2**: @username_3 Good to know, I don't think that function was around when I started with ggplot2.  
  > **username_3**: Yes, I think it was added somewhat recently (precisely because `geom_bar` has such a wonky default).  
  > **username_1**: "This isn't a bioinformatics question, but it's quicker to answer than to close." Nevertheless we can close it.  
  
  ---
  
  