s-news
[Top] [All Lists]

count occurrences

To: S-news <s-news@lists.biostat.wustl.edu>
Subject: count occurrences
From: Ita Cirovic <zag_cirovic@yahoo.com>
Date: Fri, 3 Aug 2007 03:17:37 -0700 (PDT)
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type:Message-ID; b=ZbwyvW53BHshsD+P09P1z7DWujLcZ7c2UqzbgWVCkb9FuPFW5DEXi/Mp6ds5u8lZXFQOCU3frftxqiC7UhlOVZkBPd78JrxITQTFf2+16Fg/KNC4t76p5epAj47POIk49o0QfsVgT9asKbdubiKkL2sUpcN2H2CIgFdRXvW2o8k=;
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.


Pinpoint customers who are looking for what you sell.
<Prev in Thread] Current Thread [Next in Thread>