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.
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.
R-code that I performed:
predicted & experimental contains an array of xy values (differing lengths, start and end X values).
cdf_e<-ewcdf(experimental[,1],weights=experimental[,2])
cdf_p<-ewcdf(predicted[,1],weights=predicted[,2])
ks.test(cdf_e,cdf_p)
The message i get is:
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'
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.
PS: The first 10 lines of each data file is as follows:
predicted
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
Experimental
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