Skip to content
Prev 138344 / 398506 Next

Help needed in R

It works.

Thank you so much.

Abou



==========================
AbouEl-Makarim Aboueissa, Ph.D.
Assistant Professor of Statistics
Department of Mathematics & Statistics
University of Southern Maine
96 Falmouth Street
P.O. Box 9300
Portland, ME 04104-9300

Tel: (207) 228-8389
Fax: (207) 780-5607
Email: aaboueissa at usm.maine.edu
          aboueiss at yahoo.com
Office: 301C Payson Smith
I guess you are looking for the number of rows satisfying the following
condition.
Assuming that you have a cutoff k = 1, 2, 5, 10, 15
1) x[i,1] < k regardless of the value of x[i,2], OR
2) x[i,1] == k and x[i,2] == 1

Here is my take on this problem. It is not elegant but it seems to do the
job.
<-matrix(c(2,2,12,2,1,10,10,4,10,1,1,2,2,1,2,10,3,1,1,1,3,5,17,23,9,9,3,3,15,5,
+                  4,5,5,5,4,8,1,15,3,3,1,6,3,6,3,4,5,14,4,
+
0,0,0,0,0,1,1,0,1,1,0,1,1,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,1,1,0,1,1,1,0,
+                  0,0,0,0,0,0,0,0,0,0,0,0,0,0),49,2)
+     x1 <- x[,1]
+     x2 <- x[,2]
+     sum(x1 < cutoff | ((x1 == cutoff )& (x2==1)))
+ }
[1]  2 11 33 43 46