title: R boxplot - how to normalize against given high and low limits instead of min and max
body: <p>I have several measurements, which need to be presented in same boxplot chart, despite having completely different scales. Each group (=measurement type) has their own specific high and low acceptance limits. </p>
  
  <p>The data should be normalized in R so that the low limit is always -1, and high limit always +1 across all groups. I'll then set the Y-axis so that all measurements are properly displayed. </p>
  
  <p>So far I've managed to draw the boxplot with min(NUM_VALUE) being -1 and max(NUM_VALUE) being +1, but this is not the final result I want.</p>
  
  <p>fake data (just part of the table):</p>
  
  <pre><code>ITEMID      NAME    SERIALID    NUM_VALUE   LOWER_LIMIT UPPER_LIMIT
  Itemcode1   group1  SN1000      62.1        50          80
  Itemcode1   group1  SN1001      62.6        50          80
  Itemcode1   group1  SN1002      63.9        50          80
  Itemcode1   group2  SN1006      1526.79     1526        1528
  Itemcode1   group2  SN1007      1526.799    1526        1528
  Itemcode1   group3  SN1015      1815.09     1814        1816
  Itemcode1   group3  SN1016      1815.094    1814        1816
  Itemcode1   group3  SN1017      1815.098    1814        1816
  Itemcode1   group4  SN1025      1526.751    1526        1527
  Itemcode1   group4  SN1026      1526.62     1526        1527
  Itemcode1   group5  SN1028      1816.155    1816        1817
  Itemcode1   group5  SN1029      1816.245    1816        1817
  </code></pre>
  
  <p>R code:</p>
  
  <pre><code>library(ggplot2)
  library(data.table)
  df &lt;- read.table("data3.csv", header=TRUE, sep=";", stringsAsFactors=FALSE)
  skl &lt;- function(x){(x-min(x))/(max(x)-min(x))*2-1}
  df &lt;- transform(df,scaled=ave(df$NUM_VALUE,df$NAME,FUN=skl))
  ggplot(df, aes(x=df$NAME, y = df$scaled)) + geom_boxplot()
  </code></pre>
  
  <p>Graph so far:
  <a href="https://i.stack.imgur.com/IokA1.png" rel="nofollow noreferrer">boxplot</a></p>
  
  <p>I'm very new to R. </p>
  
  <p>Question: How to scale boxplot against UPPER_LIMIT and LOWER_LIMIT by group and present it all in same graph?</p>
  
  <p>Any help highly appreciated, thank you!</p>