3 Aug 2007 12:17
count occurrences
Ita Cirovic <zag_cirovic <at> yahoo.com>
2007-08-03 10:17:37 GMT
2007-08-03 10:17:37 GMT
Given two data sets I would like to count the occurrences of one dependent on the other. For example,
upb is defined as follows
P4 P5
[1,] -0.0406703026 0.02952575
[2,] 0.0008282428 0.06102947
[3,] 0.0098109756 0.08774035
[4,] 0.0183787962 0.11517816
[5,] 0.0275845430 0.14899661
[6,] 0.0390078215 0.19359835
[7,] 0.0541145248 0.26253533
[8,] 0.0772375923 0.37398115
[9,] 0.1228048769 0.58875809
[10,] 0.9980051666 7.41044290
then I have a data set which consists of the original values of the variable sP4 and P5 with the number of observations of around 11000. What I would like to do is to count how many observations of P4 are smaller than opb[1,1] and then for upb[2,1] and so on. Also this I would like to do for the other variable P5. The results would be stored in another matrix say obs with dim(obs) = 10x2.
I have been trying to do this using for loops and if statements, but was wondering whether there was an easier way, for example some S-PLUS function that would do count given the condition. Thanks.
upb is defined as follows
P4 P5
[1,] -0.0406703026 0.02952575
[2,] 0.0008282428 0.06102947
[3,] 0.0098109756 0.08774035
[4,] 0.0183787962 0.11517816
[5,] 0.0275845430 0.14899661
[6,] 0.0390078215 0.19359835
[7,] 0.0541145248 0.26253533
[8,] 0.0772375923 0.37398115
[9,] 0.1228048769 0.58875809
[10,] 0.9980051666 7.41044290
then I have a data set which consists of the original values of the variable sP4 and P5 with the number of observations of around 11000. What I would like to do is to count how many observations of P4 are smaller than opb[1,1] and then for upb[2,1] and so on. Also this I would like to do for the other variable P5. The results would be stored in another matrix say obs with dim(obs) = 10x2.
I have been trying to do this using for loops and if statements, but was wondering whether there was an easier way, for example some S-PLUS function that would do count given the condition. Thanks.
Pinpoint customers who are looking for what you sell.
RSS Feed