title: Problems with nonlinear least square fit nls non-numeric argument with binary operator
body: <p>I just started working with R and would like to get a Nonlinear least square fit nls(...) to the formula y=A(1-exp(-bL))+R.
  I define my function g by</p>
  
  <pre><code>&gt; g&lt;-function(x,y,A,b,R) {
      y~A(1-exp(-bx))+R
      }
  </code></pre>
  
  <p>and want to perform nls by </p>
  
  <pre><code>&gt;nls((y~g(x,y,A,b,R)),data=Data, start=list(A=-2,b=0,R=-5))
  </code></pre>
  
  <p>And I end with the following error message.</p>
  
  <pre><code>&gt;Error in lhs - rhs : non-numeric argument to binary operator
  </code></pre>
  
  <p>I guess it's just a stupid basic mistake by another beginner, but I'd be extremely glad if anyone could help me out.</p>
  
  <p>Next question would be, whether I can implement the fitted curve into my graph</p>
  
  <pre><code>&gt;plot(x,y,main="VI.20.29")
  </code></pre>
  
  <p>Thanks to everyone taking time to read and hopefully answer my question!</p>
  
  <p>Detailed information:
  I have a table with the x values (Light.intensity) and y values (e.g. VI.20.29)</p>
  
  <pre><code>&gt; photo.data&lt;-read.csv("C:/X/Y/Z.csv", header=T)
      &gt; names(photo.data)
       [1] "Light.intensity" "SR.8.6"          "SR.8.7"         
       [4] "SR.8.18"         "SR.8.20"         "VI.20.1"        
       [7] "VI.20.5"         "VI.20.20"        "VI.20.29"       
      [10] "DP.19.1"         "DP.19.15"        "DP.19.33"       
      [13] "DP.19.99"       
      &gt; x&lt;-photo.data$Light.intensity
      &gt; x
      [1]    0   50  100  200  400  700 1000 1500 2000
      &gt; y&lt;-photo.data$VI.20.29
      &gt; y
      [1] -2.76 -2.26 -1.72 -1.09  0.18  0.66  1.47  1.48  1.63
      &gt; plot(x,y,main="VI.20.29")
      &gt; Data&lt;-data.frame(x,y)
      &gt; Data
           x     y
      1    0 -2.76
      2   50 -2.26
      3  100 -1.72
      4  200 -1.09
      5  400  0.18
      6  700  0.66
      7 1000  1.47
      8 1500  1.48
      9 2000  1.63
      &gt; g&lt;-function(x,y,A,b,R) {
      +   y~A(1-exp(-bx))+R
      +   }
      &gt; nls((y~g(x,y,A,b,R)),data=Data, start=list(A=-2,b=0,R=-5))
      Error in lhs - rhs : non-numeric argument to binary operator
  </code></pre>