title: Solving a system of 50 non-linear equations - error in fn(par,...) : argument is missing
body: <p>I am trying to solve a system of 50 non-linear equations as follows:</p>
  
  <p>Given a vector, y, which contains 49 different values, I'd like to transfer these 49 values into slightly different values in another vector, say, x such that:</p>
  
  <pre><code>log(x[1], y[1]) = n
  ...
  log(x[49], y[49]) = n
  x[1] + ... + x[49] = 1
  </code></pre>
  
  <p>For reasons of clarity, in the above equations <code>y[i]</code> is meant to be the base of the logarithm.</p>
  
  <p>I've written the following code which, however, does not seem to work:</p>
  
  <pre><code>library(xlsx)
  rm(list=ls())
  setwd("C:/Users/.../folder")
  
  my_data &lt;- read.xlsx("samplefile.xlsx", 1)
  y &lt;- matrix(0:0, nrow=49,ncol=1)
  
  for(i in 1:49) {
    if(my_data[i,1]!=0) {
      y[i,1] = 1/my_data[i,1]
      }
    }
  
  for(i in 1:49) {
    fn &lt;- function(x,n) {
    dummy1 &lt;- log(x[i],y[i])-n
    dummy2 &lt;- sum(x[1:49])-1
  
    return(c(dummy1,dummy2))
  }
  }
  
  guess &lt;- matrix(0.5:0.5, nrow = 50, ncol = 1)
  
  nleqslv(guess,fn)
  </code></pre>
  
  <p>I'd expect that it solves for for <code>x[i]</code> and <code>n</code>. However, I get the following error message:</p>
  
  <p>"Error in fn(par, ...) : argument "n" is missing, with no default"</p>
  
  <p>Edit: Formatting</p>