Additive log ratio transformation on a dataset using alr() | addLR()
<p>I am attempting to perform an additive log ratio transformation on a dataset. When I run the addLR() function, I receive the error code: </p>

<blockquote>
  <p>Error in if (dim(x)[2] &lt; 2) stop("data must be of dimension greater equal 2") : argument is of length zero</p>
</blockquote>

<p>When I run <code>str(df)</code> the structure of my data frame returns as: </p>

<pre><code>'data.frame':   1020 obs. of  2 variables:
 $ SUB: int  1 1 1 1 1 1 1 1 1 1 ...
 $ NEW  : num  2.5 351.4 0.9 49.8 80 ...
</code></pre>

<p>Here's my code: </p>

<pre><code>df &lt;- read.csv("data.csv",head=TRUE,sep=",")
df$newVar &lt;- addLR(df$NEW, ivar=ncol(df$SUB))
</code></pre>

<p>I've also used the function </p>

<pre><code>df$newVar &lt;- alr(df$NEW, ivar=ncol(df$SUB))
</code></pre>

<p>but only receive the error message </p>

<blockquote>
  <p>Error in -ivar : invalid argument to unary operator</p>
</blockquote>

<p>I've tried altering the class of both variables (i.e.<code>df$SUB &lt;- as.character(df$SUB)</code>), as well as ensuring the length of both columns are equal (they are). </p>