[R] Newbie needs a count() function

Art Salwin salwin at mitretek.org
Tue Mar 28 21:41:26 CEST 2000

Is there a count() function in R that tells how many
elements of a vector meet a certain criterion?  (Need it for
generating contour plots.)

Currently I use the somewhat cumbersome
count<-length(v[v<7]) to determine, for example, the number
of elements
in v that are <7.  (Note that count<-length(x[v<7]) would
also work,
where x is *any* vector that has the same length as v.)
Art Salwin
salwin at mitretek.org
(202) 863-2985
(202) 863-2988 (fax)
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list