Dear ALL:
Please see below. I hope this will make it more clear.
[1,] 1 1
[2,] 1 1 number of all observations less than 1 with
indicator 1 (including those 1 with indicator 1 but not 1 with
indicator 0)=2
[3,] 1 0
[4,] 1 0
[5,] 1 0
[6,] 1 0
[7,] 1 0
[8,] 1 0
[9,] 1 0
[10,] 2 1
[11,] 2 1 number of all observations less than 2 with
indicator 1 (including those 2 with indicator 1 but not 2 with
indicator 0)=11
[12,] 2 0
[13,] 2 0
[14,] 2 0
[15,] 2 0
[16,] 3 0
[17,] 3 0
[18,] 3 0
[19,] 3 0
[20,] 3 0
[21,] 3 0
[22,] 3 0
[23,] 3 0
[24,] 4 0
[25,] 4 0
[26,] 4 0
[27,] 4 0
[28,] 4 0
[29,] 5 1
[30,] 5 1
[31,] 5 1
[32,] 5 1
[33,] 5 1 number of all observations less than 5 with indicator
1 (including those 5 with indicator 1 but not 5 with indicator 0)=33
[34,] 5 0
[35,] 6 0
[36,] 6 0
[37,] 8 0
[38,] 9 0
[39,] 9 0
[40,] 10 1
[41,] 10 1
[42,] 10 1
[43,] 10 1 number of all observations less than 10 with indicator
1 (including those 10 with indicator 1 but not 10 with indicator 0)=43
[44,] 12 0
[45,] 14 0
[46,] 15 1 number of all observations less than 15 with
indicator 1 (including those 15 with indicator 1 but not 15 with
indicator 0)=46
[47,] 15 0
[48,] 17 0
[49,] 23 0
How I can write an R code to do this.
Thanks
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
"Henrique Dallazuanna" <wwwhsd at gmail.com> 3/3/2008 11:38 AM >>>
For me is not very clear, but if I understand:
sapply(sort(unique(data[data[,2]==1,1])),
function(x)sum(data[data[,2]==1 & data[,1] <= x, 1]))
But the output is:
2 6 31 71 86
On 03/03/2008, AbouEl-Makarim Aboueissa <aaboueissa at usm.maine.edu>
wrote:
Dear Ellison:
it did not do it.
I edited my previous email to make my question more clear.
The out put should be: (2,11,33,43,46)
For example:
number of all observations less than 1 with indicator 1 (including
those 1 with indicator 1 but not 1 with indicator 0) =2
number of all observations less than 2 with indicator 1 (including
those 2 with indicator 1 but not 2 with indicator 0) =11
number of all observations less than 5 with indicator 1 (including
those 5 with indicator 1 but not 5 with indicator 0) =33
number of all observations less than 10 with indicator 1 (including
those 10 with indicator 1 but not 10 with indicator 0) =43
number of all observations less than 15 with indicator 1 (including
those 15 with indicator 1 but not 15 with indicator 0) =46
(1, 2,5,10,15) are the values in column one with indicator 1 in
column two.
which means I need to create a vector(2,11,33,43,46) for the data in
column one.
==========================
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
"S Ellison" <S.Ellison at lgc.co.uk> 3/3/2008 10:36 AM >>>
table(data[data[,2]==1,1])
>>> "AbouEl-Makarim Aboueissa" <aaboueissa at usm.maine.edu>
03/03/2008
15:20:21 >>>
Dear ALL:
How I can find the number of observations less than each value in
column one with indicator 1 in column two. Please see the data
below.
For example: number of observations less than 1 with indicator 1
(including those 1 with indicator 1) =2
number of observations less than 2 with indicator
1
(including those 2 with indicator 1) =11
number of observations less than 5 with indicator
1
(including those 5 with indicator 1) =33
number of observations less than 10 with
indicator
1 (including those 10 with indicator 1) =43
number of observations less than 15 with
indicator
1 (including those 15 with indicator 1) =46
(1, 2,5,10,15) are the values in column one with indicator 1 in
column
two.
which means I need to create a vector(2,11,33,43,46) for the data
in
column one.
With many thanks.
Abou
Here is the data:
===========
Consider the following matrix:
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
*******************************************************************
This email and any attachments are confidential. Any