Hi all, I take a simple dataset like this: -1.3 1 -1.5 -1 1.5 -2.5 3 -0.5 Now I want to count how many values there are between -2 and 2. The answer here would be 6. Can anyone do this with R? Thank you in advance. Gr. Bosken -- View this message in context: http://n4.nabble.com/Count-between-interval-tp1564537p1564537.html Sent from the R help mailing list archive at Nabble.com.
Hi, ab<-read.table(header=F,file=textConnection("-1.3 1 -1.5 -1 1.5 -2.5 3 -0.5")) length(which(ab >=-2 & ab<=2)) Bosken schrieb:> Hi all, > > I take a simple dataset like this: > > -1.3 > 1 > -1.5 > -1 > 1.5 > -2.5 > 3 > -0.5 > > Now I want to count how many values there are between -2 and 2. > > The answer here would be 6. > > Can anyone do this with R? > > Thank you in advance. > > Gr. Bosken >-- Eik Vettorazzi Institut f?r Medizinische Biometrie und Epidemiologie Universit?tsklinikum Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790
Hi, Here is a suggeston:> x <- c(-1.3, 1, -1.5, -1, 1.5, -2.5, 3, -0.5) > sum(x >=-2 & x<=2)[1] 6 HTH, Jorge On Mon, Feb 22, 2010 at 9:49 AM, Bosken <> wrote:> > Hi all, > > I take a simple dataset like this: > > -1.3 > 1 > -1.5 > -1 > 1.5 > -2.5 > 3 > -0.5 > > Now I want to count how many values there are between -2 and 2. > > The answer here would be 6. > > Can anyone do this with R? > > Thank you in advance. > > Gr. Bosken > -- > View this message in context: > http://n4.nabble.com/Count-between-interval-tp1564537p1564537.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. >[[alternative HTML version deleted]]
And as long as the interval is symmetric about zero: sum(abs(x) <= 2) [1] 6 -Peter Ehlers On 2010-02-22 9:18, Jorge Ivan Velez wrote:> Hi, > > Here is a suggeston: > > >> x<- c(-1.3, 1, -1.5, -1, 1.5, -2.5, 3, -0.5) >> sum(x>=-2& x<=2) > [1] 6 > > HTH, > Jorge > > > On Mon, Feb 22, 2010 at 9:49 AM, Bosken<> wrote: > >> >> Hi all, >> >> I take a simple dataset like this: >> >> -1.3 >> 1 >> -1.5 >> -1 >> 1.5 >> -2.5 >> 3 >> -0.5 >> >> Now I want to count how many values there are between -2 and 2. >> >> The answer here would be 6. >> >> Can anyone do this with R? >> >> Thank you in advance. >> >> Gr. Bosken >> -- >> View this message in context: >> http://n4.nabble.com/Count-between-interval-tp1564537p1564537.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. >> > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. > >-- Peter Ehlers University of Calgary
Reasonably Related Threads
- Normal distribution (Lillie.test())
- how to draw confidence interval lines of a fitted curve of polynominal regression
- ccf documentation bug or suggeston (PR#9394)
- regression coefficient for different factors
- count data without NA in certain time intervals and plot it