[R] calculating probability

David Winsemius dwinsemius at comcast.net
Mon Aug 24 15:01:47 CEST 2009

On Aug 24, 2009, at 8:11 AM, maram salem wrote:

> Hi all,
> I've a trivial question. If (q) is a continous variable,actually a  
> vector of 1000 values. how to calculate the probability that q is  
> greater than a specific value, i.e. P(q>45)??

sum(q>45)/1000  # if no NA's in vector
sum(q>45, na.rm=TRUE)/ sum(!is.na(q))  # if NA's in vector


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

More information about the R-help mailing list