Hi>i have this data> X[1] 5.79 1579.52 2323.70 68.85 426.07 110.29 108.29 1067.60 17.05 22.66 [11] 21.02 175.88 139.07 144.12 20.46 43.40 194.90 47.30 7.74 0.40 [21] 82.85 9.88 89.29 215.10 1.75 0.79 15.93 3.91 0.27 0.69 [31] 100.58 27.80 13.95 53.24 0.96 4.15 0.19 0.78 8.01 31.75 [41] 7.35 6.50 8.27 33.91 32.52 3.16 4.85 2.78 4.67 1.31 [51] 12.06 36.71 72.89 1.97 0.59 2.58 1.69 2.71 25.50 0.35 [61] 0.99 3.99 3.67 2.07 0.96 5.35 2.90 13.77 0.47 0.73 [71] 1.40 0.74 0.39 1.13 0.09 2.38 >and i have an intervale I[j]<- leftaj, rightaj HERE I CAN T PROGRAMATE THIS INTERVAL>SO i have>> leftaj[1] 0 1.179 3.729 9.418 18.010 29.746 58.662 131.566> rightaj[1] 1.179 3.729 9.418 18.010 29.746 58.662 131.566 2323.700 >i want to counting the number of X hows in the intervale [leftaj, rightaj]>thanks for helping >hafida-- View this message in context: http://r.789695.n4.nabble.com/help-counting-in-data-tp4640033.html Sent from the R help mailing list archive at Nabble.com.
HI, Not sure whether this is what you wanted. dat3<-c(5.79, 1579.52, 2323.70, 68.85,? 426.07,? 110.29, 108.29, 1067.60,? 17.05, 22.66, ?21.02,? 175.88,? 139.07,? 144.12, 20.46,? 43.40, 194.90, 47.30,? 7.74, 0.40, ? 82.85, 9.88, 89.29,? 215.10, 1.75,? 0.79, 15.93,? 3.91,? 0.27,? 0.69, ?100.58, 27.80, 13.95, 53.24,? 0.96, 4.15, 0.19, 0.78, 8.01,? 31.75, ?7.35, 6.50, 8.27, 33.91, 32.52, 3.16, 4.85, 2.78, 4.67, 1.31, ?12.06, 36.71, 72.89, 1.97, 0.59, 2.58, 1.69, 2.71, 25.50, 0.35, ?0.99, 3.99, 3.67, 2.07, 0.96, 5.35, 2.90, 13.77, 0.47,? 0.73, 1.40, 0.74, 0.39, 1.13, 0.09, 2.38) leftaj<-c( 0, 1.179,3.729,9.418, 18.010, 29.746, 58.662, 131.566) rightaj<-c(1.179, 3.729, 9.418, 18.010, 29.746, 58.662, 131.566, 2323.700) ?leftajmax<-max(leftaj) ?rightajmax<-max(rightaj) ?leftajmin<-min(leftaj) rightajmin<-min(rightaj) dat3[(dat3<rightajmax & dat3>leftajmax)|(dat3>leftajmin & dat3<rightajmin)] ?#[1] 1579.52? 426.07 1067.60? 175.88? 139.07? 144.12? 194.90??? 0.40? 215.10 #[10]??? 0.79??? 0.27??? 0.69??? 0.96??? 0.19??? 0.78??? 0.59??? 0.35??? 0.99 #[19]??? 0.96??? 0.47??? 0.73??? 0.74??? 0.39??? 1.13??? 0.09 ?length(dat3[(dat3<rightajmax & dat3>leftajmax)|(dat3>leftajmin & dat3<rightajmin)]) #[1] 25 A.K. ----- Original Message ----- From: hafida <hafida-06 at hotmail.fr> To: r-help at r-project.org Cc: Sent: Saturday, August 11, 2012 9:59 AM Subject: [R] help counting in data Hi>i have this data> X[1]? ? 5.79 1579.52 2323.70? 68.85? 426.07? 110.29? 108.29 1067.60? 17.05? 22.66 [11]? 21.02? 175.88? 139.07? 144.12? 20.46? 43.40? 194.90? 47.30? ? 7.74? 0.40 [21]? 82.85? ? 9.88? 89.29? 215.10? ? 1.75? ? 0.79? 15.93? ? 3.91? ? 0.27? 0.69 [31]? 100.58? 27.80? 13.95? 53.24? ? 0.96? ? 4.15? ? 0.19? ? 0.78? ? 8.01? 31.75 [41]? ? 7.35? ? 6.50? ? 8.27? 33.91? 32.52? ? 3.16? ? 4.85? ? 2.78? ? 4.67? 1.31 [51]? 12.06? 36.71? 72.89? ? 1.97? ? 0.59? ? 2.58? ? 1.69? ? 2.71? 25.50? 0.35 [61]? ? 0.99? ? 3.99? ? 3.67? ? 2.07? ? 0.96? ? 5.35? ? 2.90? 13.77? ? 0.47? 0.73 [71]? ? 1.40? ? 0.74? ? 0.39? ? 1.13? ? 0.09? ? 2.38>and i have an intervale? ? ? I[j]<- leftaj, rightaj? ? ? ? ? ? HERE I CANT PROGRAMATE THIS INTERVAL>SO i have>> leftaj[1]? ? 0? ? ? ? ? 1.179? 3.729? 9.418? 18.010? 29.746? 58.662 131.566> rightaj[1]? ? 1.179? ? 3.729? ? 9.418? 18.010? 29.746? 58.662? 131.566 2323.700>i want to counting the number of? X? ? hows in the intervale? ? [leftaj,rightaj]>thanks for helping >hafida-- View this message in context: http://r.789695.n4.nabble.com/help-counting-in-data-tp4640033.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.
use 'dput' to enclose your data. I think 'cut' is what you want:> dput(x)c(0, 1.179, 3.729, 9.418, 18.01, 29.746, 58.662, 131.566, 2323.7 )> dput(y)c(5.79, 1579.52, 2323.7, 68.85, 426.07, 110.29, 108.29, 1067.6, 17.05, 22.66, 21.02, 175.88, 139.07, 144.12, 20.46, 43.4, 194.9, 47.3, 7.74, 0.4, 82.85, 9.88, 89.29, 215.1, 1.75, 0.79, 15.93, 3.91, 0.27, 0.69, 100.58, 27.8, 13.95, 53.24, 0.96, 4.15, 0.19, 0.78, 8.01, 31.75, 7.35, 6.5, 8.27, 33.91, 32.52, 3.16, 4.85, 2.78, 4.67, 1.31, 12.06, 36.71, 72.89, 1.97, 0.59, 2.58, 1.69, 2.71, 25.5, 0.35, 0.99, 3.99, 3.67, 2.07, 0.96, 5.35, 2.9, 13.77, 0.47, 0.73, 1.4, 0.74, 0.39, 1.13, 0.09, 2.38)> z <- cut(y, x) > table(z)z (0,1.18] (1.18,3.73] (3.73,9.42] (9.42,18] (18,29.7] 17 13 12 6 5 (29.7,58.7] (58.7,132] (132,2.32e+03] 7 7 9 On Sat, Aug 11, 2012 at 9:59 AM, hafida <hafida-06@hotmail.fr> wrote:> Hi > > > >i have this data > > > X > [1] 5.79 1579.52 2323.70 68.85 426.07 110.29 108.29 1067.60 > 17.05 > 22.66 > [11] 21.02 175.88 139.07 144.12 20.46 43.40 194.90 47.30 > 7.74 > 0.40 > [21] 82.85 9.88 89.29 215.10 1.75 0.79 15.93 3.91 > 0.27 > 0.69 > [31] 100.58 27.80 13.95 53.24 0.96 4.15 0.19 0.78 > 8.01 > 31.75 > [41] 7.35 6.50 8.27 33.91 32.52 3.16 4.85 2.78 > 4.67 > 1.31 > [51] 12.06 36.71 72.89 1.97 0.59 2.58 1.69 2.71 > 25.50 > 0.35 > [61] 0.99 3.99 3.67 2.07 0.96 5.35 2.90 13.77 > 0.47 > 0.73 > [71] 1.40 0.74 0.39 1.13 0.09 2.38 > > >and i have an intervale I[j]<- leftaj, rightaj HERE I > CAN > T PROGRAMATE THIS INTERVAL > > >SO i have > > >> leftaj > [1] 0 1.179 3.729 9.418 18.010 29.746 58.662 131.566 > > rightaj > [1] 1.179 3.729 9.418 18.010 29.746 58.662 131.566 2323.700 > > > >i want to counting the number of X hows in the intervale [leftaj, > rightaj] > > >thanks for helping > >hafida > > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/help-counting-in-data-tp4640033.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@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. >-- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. [[alternative HTML version deleted]]
Hello, Post your data using dput(). Copy the output of dput(X) and paste it in a post. Anyway, you can try the following. sum( leftaj <= X & X <= rightaj ) Hope this helps, Rui Barradas Em 11-08-2012 14:59, hafida escreveu:> Hi > > >> i have this data >> X > [1] 5.79 1579.52 2323.70 68.85 426.07 110.29 108.29 1067.60 17.05 > 22.66 > [11] 21.02 175.88 139.07 144.12 20.46 43.40 194.90 47.30 7.74 > 0.40 > [21] 82.85 9.88 89.29 215.10 1.75 0.79 15.93 3.91 0.27 > 0.69 > [31] 100.58 27.80 13.95 53.24 0.96 4.15 0.19 0.78 8.01 > 31.75 > [41] 7.35 6.50 8.27 33.91 32.52 3.16 4.85 2.78 4.67 > 1.31 > [51] 12.06 36.71 72.89 1.97 0.59 2.58 1.69 2.71 25.50 > 0.35 > [61] 0.99 3.99 3.67 2.07 0.96 5.35 2.90 13.77 0.47 > 0.73 > [71] 1.40 0.74 0.39 1.13 0.09 2.38 > > >and i have an intervale I[j]<- leftaj, rightaj HERE I CAN > T PROGRAMATE THIS INTERVAL > >> SO i have >>> leftaj > [1] 0 1.179 3.729 9.418 18.010 29.746 58.662 131.566 >> rightaj > [1] 1.179 3.729 9.418 18.010 29.746 58.662 131.566 2323.700 > > > >i want to counting the number of X hows in the intervale [leftaj, > rightaj] > >> thanks for helping >> hafida > > > > -- > View this message in context: http://r.789695.n4.nabble.com/help-counting-in-data-tp4640033.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.