Do you mean something like this? Calculating the mean of a Logical vector gives you the fraction of elements that are TRUE because TRUE is equal to 1 and False is equal to 0.
data("swiss")
swiss$Evg_region <- swiss$Catholic < 25.0
head(swiss)
Fertility Agriculture Examination Education Catholic Infant.Mortality Evg_region
Courtelary 80.2 17.0 15 12 9.96 22.2 TRUE
Delemont 83.1 45.1 6 9 84.84 22.2 FALSE
Franches-Mnt 92.5 39.7 5 5 93.40 20.2 FALSE
Moutier 85.8 36.5 12 7 33.77 20.3 FALSE
Neuveville 76.9 43.5 17 15 5.16 20.6 TRUE
Porrentruy 76.1 35.3 9 7 90.57 26.6 FALSE
mean(swiss$Evg_region)
[1] 0.5744681