text: user6470: I have got a fold-change dataset and I simply would like to plot something like this:
  
  The problem is that I have only numbers in my columns and when I use a boxplot() function I can plot only boxes but not dots, jitter, etc.
  I use this code to build a df and then proceed to a boxplot
  A <- c(-1, 25, 3, 4, 50)
  B <- c(23, -41, 32, 68, 26)
  C <- c(63, 71, 22, -8, 2)
  D <- c(16, -49, 2, 56, 6)
  df <- data.frame(A, B, C, D)
  print (df)
  boxplot(df) 
  
  How can I plot something that looks like the above picture? Thanks
  
  user3967: To coerce your data into a form interpretable by ggplot2, you can use the gather function from tidyr.
  gather has been superseded by pivot_longer.
  library(tidyverse)
  df <- tibble(A = c(-1, 25, 3, 4, 50),
               B = c(23, -41, 32, 68, 26),
               C = c(63, 71, 22, -8, 2),
               D = c(16, -49, 2, 56, 6))
  
  tidyr::pivot_longer(data = df, cols = c(A,B,C,D)) |>
    ggplot(mapping = aes(x = name, y = value)) +
    geom_boxplot() +
    geom_dotplot(binaxis = "y", stackdir = "center") +
    theme_classic()
  
  
  
original_text: 6470: <p>I have got a fold-change dataset and I simply would like to plot something like this:</p>
  <p><a href="https://i.stack.imgur.com/DbhJG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DbhJG.jpg" alt="enter image description here" /></a></p>
  <p>The problem is that I have only numbers in my columns and when I use a boxplot() function I can plot only boxes but not dots, jitter, etc.</p>
  <p>I use this code to build a df and then proceed to a boxplot</p>
  <pre><code>A &lt;- c(-1, 25, 3, 4, 50)
  B &lt;- c(23, -41, 32, 68, 26)
  C &lt;- c(63, 71, 22, -8, 2)
  D &lt;- c(16, -49, 2, 56, 6)
  df &lt;- data.frame(A, B, C, D)
  print (df)
  boxplot(df) 
  </code></pre>
  <p>How can I plot something that looks like the above picture? Thanks</p>
   3967: <p><strike>To coerce your data into a form interpretable by <code>ggplot2</code>, you can use the <code>gather</code> function from <code>tidyr</code>.</strike></p>
  <p><code>gather</code> has been superseded by <code>pivot_longer</code>.</p>
  <pre><code>library(tidyverse)
  df &lt;- tibble(A = c(-1, 25, 3, 4, 50),
               B = c(23, -41, 32, 68, 26),
               C = c(63, 71, 22, -8, 2),
               D = c(16, -49, 2, 56, 6))
  
  tidyr::pivot_longer(data = df, cols = c(A,B,C,D)) |&gt;
    ggplot(mapping = aes(x = name, y = value)) +
    geom_boxplot() +
    geom_dotplot(binaxis = &quot;y&quot;, stackdir = &quot;center&quot;) +
    theme_classic()
  </code></pre>
  <p><a href="https://i.stack.imgur.com/knu0J.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/knu0J.png" alt="enter image description here" /></a></p>
  