我有一个文本,例如
text<- "i am happy today :):)"
Run Code Online (Sandbox Code Playgroud)
我想从文本向量中提取:)并报告其频率
这是一个很容易概括的想法:
text<- c("i was happy yesterday :):)",
"i am happy today :)",
"will i be happy tomorrow?")
(nchar(text) - nchar(gsub(":)", "", text))) / 2
# [1] 2 1 0
Run Code Online (Sandbox Code Playgroud)