# Frequency of a value in R [closed]

If there is a data set in R and I want know how many of one value is in it, is there a command for this? thanks

If the values are discrete, you can just use

summary(factor(x))

If you just want to know how often a specific value occurs, then the snippet

sum(x==v)

works quite nicely. Beware of NAs, however (e.g. using na.rm=T).

If the value is not discrete, then the notion of "frequency" becomes somewhat ill-defined. The above approach would still work, but I would be very cautious about interpreting the results.

• table(x) is often helpful as an alternative Apr 8 '20 at 10:14