Hi, The logical operators are actually vectorized, so I do not think you need a loop. Does this do what you want?
## Some data set.seed(10) dat <- matrix(rnorm(500, sd = 3), nrow = 80) ## Hypothetical confidence interval ci <- c(-5, 5) ## Find the number of points outside interval sum(dat < ci[1] | dat > ci[2], na.rm = TRUE) Cheers, Josh On Sun, Feb 13, 2011 at 4:26 PM, Syd88 <jhea2...@uni.sydney.edu.au> wrote: > > Hi, > I am trying to determine how many points fall ouside the confidence interval > range. > > This is the code I have so far but it does not work. Any help would be > appreciated. > > Count <- vector () > for (i in 1: nrow (dataname)){ > if (dataname[i] <l.ci.post[1]// > dataname[i] >u.ci.post[i]){ > count[i] -> 1 > }else > {count[i] -> 0} > } > > > > symbol > // = or - not sure if this is the right symbol though > -- > View this message in context: > http://r.789695.n4.nabble.com/Confidence-interval-tp3304258p3304258.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. > -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.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.