title: Define new scales axis tranform for ggplot
body: <p>I am trying to create a <code>squared</code> transform for the y-axis using <code>scales::trans_new</code> but am hitting an error.</p>
  
  <p>MWE</p>
  
  <pre><code>data = data.frame(x = 1:10, y = runif(10), z=rnorm(10, 10))
  
  library(ggplot2)
  ggplot(data, aes(x, y, size=z)) +
  geom_point() +
  scale_y_continuous(trans=scales::trans_new("sq", function(x) x^2, function(x) x^(1/2)))
  </code></pre>
  
  <p>gives the error </p>
  
  <blockquote>
    <p>Error in if (zero_range(as.numeric(limits))) { :<br>
      missing value where TRUE/FALSE needed</p>
  </blockquote>
  
  <p>I tries adding <code>limits</code> and <code>domain</code> but got the same error.</p>
  
  <pre><code>scale_y_continuous(trans=scales::trans_new("sq", function(x) x^2, function(x) x^(1/2)), limits=c(0,1))
  scale_y_continuous(trans=scales::trans_new("sq", function(x) x^2, function(x) x^(1/2), domain=c(0,1)), limits=c(0,1))
  </code></pre>
  
  <p>It seesm to be the <code>inverse</code> argument that is causing the error - but all values of <code>y</code> are positive, so I don't understand. How can I do this please?</p>