title: Performing KS.test on empirical weighted distribution functions in R
body: <p>I want to compare two datasets with differing amounts of data and differing start/end points. I wanted to use the KS.test as I am doing something similar in a C program I wrote (compares data via GSL histogram -> GSL cdf -> self-written KS test) but as this program is unpublished still I can't use it for this. I did however want to use the same principle in R but can't seem to grasp how to do this in R.</p>
  
  <p>I have two empircal weighted distribution functions (created with the spatstat library) and am trying to perform the KS.test on them but it gives me an error that I am not quite sure how to interpret.</p>
  
  <p>R-code that I performed:</p>
  
  <p>predicted &amp; experimental contains an array of xy values (differing lengths, start and end X values).</p>
  
  <pre><code>cdf_e&lt;-ewcdf(experimental[,1],weights=experimental[,2])
  cdf_p&lt;-ewcdf(predicted[,1],weights=predicted[,2])
  ks.test(cdf_e,cdf_p)
  </code></pre>
  
  <p>The message i get is:</p>
  
  <pre><code>Error in x[!is.na(x)] : object of type 'closure' is not subsettable
  In addition: Warning message:
  In is.na(x) : is.na() applied to non-(list or vector) of type 'closure'
  </code></pre>
  
  <p>Can anyone tell me what this means specifically (as the ?ks.test doesn't mention anything that I can relate to this error) or if I should instead use a different function call or what not.</p>
  
  <p>PS: The first 10 lines of each data file is as follows:</p>
  
  <p>predicted</p>
  
  <pre><code>m/z I
  292.1 1272
  322.0 815
  324.9 780
  350.0 922
  363.9 781
  366.0 87049
  366.9 12773
  367.9 1620
  383.6 1258
  </code></pre>
  
  <p>Experimental</p>
  
  <pre><code>m/z I
  366.139 1229.62
  367.142 186.775
  368.145 10.9435
  528.192 19.8701
  529.195 4.39351
  579.435 11.5899
  680.996 73.8311
  681.861 7.2526
  745.032 5.31373
  </code></pre>