An option is also split
the vec
by the same object, get the lengths
and divide by the length
of the whole vector
lengths(split(vec, vec))/length(vec)
# agency difference Feminality location Masculinity ownership
# 0.16 0.16 0.16 0.16 0.20 0.16
Or with count
from dplyr
library(dplyr)
tibble(vec) %>%
count(vec) %>%
mutate(prop = n/sum(n))
or use adorn_percentages
from janitor
library(janitor)
tibble(vec) %>%
count(vec) %>%
adorn_percentages("col")
data
vec <- c("location", "Masculinity", "ownership", "Masculinity", "difference",
"agency", "agency", "Feminality", "ownership", "Feminality",
"ownership", "location", "agency", "Masculinity", "difference",
"location", "Feminality", "ownership", "agency", "Masculinity",
"difference", "difference", "Feminality", "location", "Masculinity"
)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…